From 2183b229e32a558e528a759efb0b31ee34e244d6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 4 Aug 2017 11:36:39 +0200 Subject: [PATCH] [module/spotify] Add new format string parameter --- bumblebee/modules/spotify.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 = ""