first
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: ft=python
|
||||
|
||||
import dbus
|
||||
try:
|
||||
sess = dbus.SessionBus()
|
||||
spotify = sess.get_object('org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
|
||||
properties = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties')
|
||||
|
||||
metadata = properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
|
||||
status = properties.Get("org.mpris.MediaPlayer2.Player", "PlaybackStatus")
|
||||
|
||||
|
||||
artist = metadata['xesam:artist'][0] if metadata['xesam:artist'] else ''
|
||||
song = metadata['xesam:title'] if metadata['xesam:title'] else ''
|
||||
album = metadata['xesam:album'] if metadata['xesam:album'] else ''
|
||||
|
||||
pause_symbol = " "
|
||||
play_symbol = " "
|
||||
|
||||
if (not song and not artist):
|
||||
print("")
|
||||
if (song == "Advertisement" or not artist):
|
||||
print(pause_symbol + "Advertisement")
|
||||
else:
|
||||
symbol = pause_symbol
|
||||
if status == "Playing":
|
||||
symbol = play_symbol
|
||||
print(f"{symbol} {song}: {artist}"[:25] + "...")
|
||||
|
||||
except dbus.exceptions.DBusException:
|
||||
print("")
|
||||
Reference in New Issue
Block a user