From 74c08cd538df7a1777bec2e0b2c9ad6657607188 Mon Sep 17 00:00:00 2001 From: ruben Date: Thu, 15 Mar 2018 08:22:44 +0100 Subject: [PATCH] Spotify segment checks for new protocol first --- powerline/segments/common/players.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 55bf69ae..9298bc90 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -308,17 +308,7 @@ Requires ``dbus`` python module. Only for players that support specific protocol class SpotifyDbusPlayerSegment(PlayerSegment): def get_player_status(self, pl): - legacy_player_status = _get_dbus_player_status( - pl=pl, - player_name='Spotify', - bus_name='com.spotify.qt', - player_path='/', - iface_prop='org.freedesktop.DBus.Properties', - iface_player='org.freedesktop.MediaPlayer2', - ) - if legacy_player_status is not None: - return legacy_player_status - return _get_dbus_player_status( + player_status = _get_dbus_player_status( pl=pl, player_name='Spotify', bus_name='org.mpris.MediaPlayer2.spotify', @@ -326,6 +316,17 @@ class SpotifyDbusPlayerSegment(PlayerSegment): iface_prop='org.freedesktop.DBus.Properties', iface_player='org.mpris.MediaPlayer2.Player', ) + if player_status is not None: + return player_status + # Fallback for legacy spotify client with different DBus protocol + return _get_dbus_player_status( + pl=pl, + player_name='Spotify', + bus_name='com.spotify.qt', + player_path='/', + iface_prop='org.freedesktop.DBus.Properties', + iface_player='org.freedesktop.MediaPlayer2', + ) spotify_dbus = with_docstring(SpotifyDbusPlayerSegment(),