From 9bff8a566040f07def85f80d7ff0cb7d169f17ed Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 13:49:26 -0500 Subject: [PATCH 1/3] Adding elapsed time to the dbus player. --- powerline/segments/common/players.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index c21dacef..05aabe3e 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -249,6 +249,7 @@ else: player = bus.get_object(bus_name, player_path) iface = dbus.Interface(player, iface_prop) info = iface.Get(iface_player, 'Metadata') + elapsed = iface.Get(iface_player, 'Position') status = iface.Get(iface_player, 'PlaybackStatus') except dbus.exceptions.DBusException: return @@ -269,6 +270,7 @@ else: 'album': album, 'artist': artist, 'title': title, + 'elapsed': _convert_seconds(elapsed / 1e6), 'total': _convert_seconds(info.get('mpris:length') / 1e6), } From 8d85c4f73b4ab1080414eecce98029e227549c6d Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 16:08:59 -0500 Subject: [PATCH 2/3] Add elapsed time to dbus players. --- powerline/segments/common/players.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 05aabe3e..e1ffe218 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -249,12 +249,19 @@ else: player = bus.get_object(bus_name, player_path) iface = dbus.Interface(player, iface_prop) info = iface.Get(iface_player, 'Metadata') - elapsed = iface.Get(iface_player, 'Position') status = iface.Get(iface_player, 'PlaybackStatus') except dbus.exceptions.DBusException: return if not info: return + + try: + elapsed = iface.Get(iface_player, 'Position') + except dbus.exceptions.DBusException: + pl.warning('Missing player elapsed time') + elapsed = None + else: + elapsed = _convert_seconds(elapsed / 1e6), album = info.get('xesam:album') title = info.get('xesam:title') artist = info.get('xesam:artist') @@ -270,7 +277,7 @@ else: 'album': album, 'artist': artist, 'title': title, - 'elapsed': _convert_seconds(elapsed / 1e6), + 'elapsed': elapsed, 'total': _convert_seconds(info.get('mpris:length') / 1e6), } From 5a53cf9f934cce27eae0856c4ea00a2a3110f46e Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 16:26:38 -0500 Subject: [PATCH 3/3] Add elapsed time to Dbus players --- powerline/segments/common/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index e1ffe218..eb32f267 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -261,7 +261,7 @@ else: pl.warning('Missing player elapsed time') elapsed = None else: - elapsed = _convert_seconds(elapsed / 1e6), + elapsed = _convert_seconds(elapsed / 1e6) album = info.get('xesam:album') title = info.get('xesam:title') artist = info.get('xesam:artist')