Skip to content

Instantly share code, notes, and snippets.

@thrasibule
Created July 7, 2017 00:50
Show Gist options
  • Save thrasibule/f91e497fff415ab7cfc25ee6c965eefc to your computer and use it in GitHub Desktop.
Save thrasibule/f91e497fff415ab7cfc25ee6c965eefc to your computer and use it in GitHub Desktop.
import pydbus
from gi.repository import GLib
def list_player_names():
bus = pydbus.SessionBus()
for n in bus.dbus.ListNames():
if n.startswith("org.mpris.MediaPlayer2"):
yield bus.get(n, "/org/mpris/MediaPlayer2")
def callback(self, metadata):
print(metadata['xesam:album'])
print(metadata['xesam:title'])
if __name__ == "__main__":
pithos = next(list_player_names())
pithos.TrackMetadataChanged.connect(callback)
GLib.MainLoop().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment