mirror of
https://github.com/dnlbauer/dotfiles.git
synced 2026-09-10 13:35:30 +00:00
17 lines
509 B
Python
Executable File
17 lines
509 B
Python
Executable File
#!/usr/bin/python2
|
|
|
|
import dbus
|
|
try:
|
|
bus = dbus.SessionBus()
|
|
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')
|
|
try:
|
|
out = str(props['xesam:artist'][0]) + " - " + str(props['xesam:title'])
|
|
except IndexError:
|
|
out = ''
|
|
print(out)
|
|
exit
|
|
except dbus.exceptions.DBusException:
|
|
exit
|