#!/usr/bin/env python
import dbus
import time
import commands
try:
purpleObject = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", \
"/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(purpleObject, \
"im.pidgin.purple.PurpleInterface")
except dbus.exceptions.DBusException:
print "Unable to connect to Pidgin! Make sure it is running."
exit(1)
class Track:
__message = ""
def setMessage(self, message):
currentStatus = purple.PurpleSavedstatusGetCurrent()
currentStatusType = purple.PurpleSavedstatusGetType(currentStatus)
currentStatusId = purple.PurplePrimitiveGetIdFromType(currentStatusType)
accounts = purple.PurpleAccountsGetAllActive()
saved = purple.PurpleSavedstatusNew("", currentStatusType)
purple.PurpleSavedstatusSetMessage(saved, message)
purple.PurpleSavedstatusActivate(saved)
def update(self):
if commands.getoutput('audtool playback-status') == 'playing':
artist = commands.getoutput('audtool current-song-tuple-data performer')
title = commands.getoutput('audtool current-song-tuple-data track_name')
message = artist + " - " + title
else:
message = ""
if self.__message != message:
self.__message = message
self.setMessage(message)
track = Track()
while True:
time.sleep(1)
track.update()
Wednesday, October 17, 2007
Less Dirty Using Dbus
Unfortunately, Audacious doesn't support dbus yet which will be supported in the upcoming 1.4. That's why audtool has to be used.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment