Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Gets the currently playing song from Pithos.
#!/usr/bin/env python
# You must initialize the gobject/dbus support for threading
# before doing anything.
import gobject
from dbus import glib
# Create a session bus.
import dbus
bus = dbus.SessionBus()
pithos_object = \
bus.get_object("net.kevinmehall.Pithos", "/net/kevinmehall/Pithos")
pithos = dbus.Interface(pithos_object, "net.kevinmehall.Pithos")
info = dict((str(k), str(v)) for k, v in pithos.GetCurrentSong().items())
except dbus.exceptions.DBusException:
print "(Nothing Playing)"
import sys
if len(sys.argv) > 1:
format = sys.argv[1]
format = "%(title)s by %(artist)s"
print format % info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment