diff --git a/bumblebee/modules/spotify.py b/bumblebee/modules/spotify.py index 22ddc6a..7086ba6 100644 --- a/bumblebee/modules/spotify.py +++ b/bumblebee/modules/spotify.py @@ -6,6 +6,8 @@ Requires the following library: * python-dbus Parameters: + * spotify.format: Format string (defaults to "{artist} - {title}") + Available values are: {album}, {title}, {artist}, {trackNumber} """ import bumblebee.input @@ -24,6 +26,7 @@ class Module(bumblebee.engine.Module): bumblebee.output.Widget(full_text=self.spotify) ) self._song = "" + self._format = self.parameter("format", "{artist} - {title}") cmd="dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify \ /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." @@ -43,7 +46,10 @@ class Module(bumblebee.engine.Module): spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties') props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata') - self._song = (str(props['xesam:artist'][0]) + " - " + str(props['xesam:title'])) + self._song = self._format.format(album=str(props.get('xesam:album')), + title=str(props.get('xesam:title')), + artist=','.join(props.get('xesam:artist')), + trackNumber=str(props.get('xesam:trackNumber'))) except Exception: self._song = ""