Saturday, 20 October 2012

Conky Exaile updated

Seems like dbus' reputation for being a bit 'changeable' is well deserved (or my code worked because of a bug). In any case, since a recent dbus update my conky exaile script had a problem - it would always start exaile if it wasnt running.

Fear not....


 #!/usr/bin/env python  
 import sys  
 import dbus  
 reload(sys)  
 sys.setdefaultencoding('utf8')  
 bus = dbus.SessionBus()  
 if bus.name_has_owner('org.exaile.Exaile'):  
  remote_object = bus.get_object("org.exaile.Exaile","/org/exaile/Exaile")  
 else:  
  print("Exaile not running")  
  sys.exit()  
 iface = dbus.Interface(remote_object, "org.exaile.Exaile")  
 status = iface.Query()  
 #print "Status: "+status  
 if status == "Not playing.":  
  print("Exaile not playing")  
  sys.exit()  
 elif "paused" in status:  
  print("Exaile is paused")  
  sys.exit()  
 title = iface.GetTrackAttr("title")  
 album = iface.GetTrackAttr("album")  
 artist = iface.GetTrackAttr("artist")  
 if iface.IsPlaying():  
  print("%s - %s (%s)"%(title, artist, album))  
 else:  
  print "Exaile is not playing"  

No comments:

Post a Comment