public
Created

Gets the currently playing song from Pithos.

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/usr/bin/env python
 
# http://wiki.python.org/moin/DbusExamples
# You must initialize the gobject/dbus support for threading
# before doing anything.
import gobject
gobject.threads_init()
 
from dbus import glib
glib.init_threads()
 
# Create a session bus.
import dbus
try:
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)"
exit(0)
 
import sys
if len(sys.argv) > 1:
format = sys.argv[1]
else:
format = "%(title)s by %(artist)s"
 
print format % info

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.