python - xmms2 track change detection for pynotify? -
i have written little script show current track playing on xmms2 on notification widget using xmms client , pynotify, when run can see widget popup current artist , title using xmmsclient methods.
can give hints how detect track change notify automatically without having run script manually?
you connect client library main loop, , register listener via broadcast_ playback_current_id method. if want playing id when script starts can call playback_current_id method.
here small adaptation of tutorial6 in xmms2-tutorial.git uses glib mainloop drive connection:
import xmmsclient import xmmsclient.glib import os import sys import gobject def cb(result): if not result.is_error(): print "current: %(artist)s - %(title)s" % result.value() ml = gobject.mainloop(none, false) xc = xmmsclient.xmms("stackoverflow") xc.connect() conn = xmmsclient.glib.glibconnector(xc) xc.broadcast_playback_current_id(lambda r: xc.medialib_get_info(r.value(), cb)) ml.run()
Comments
Post a Comment