ocarina/plugins/notify.py
Bryan Schumaker ed9d853065 Added notify plugin
This plugin will display a notification when the song is changed.
2010-12-12 16:47:42 -05:00

35 lines
699 B
Python

# Bryan Schumaker (12/12/2010)
import pynotify
import ocarina
libsaria = ocarina.libsaria
get_attrs = libsaria.sources.get_attrs
image = ocarina.components.image.Image()
def notify(*args):
title, artist, art = get_attrs("title", "artist", "art")
try:
image.set_from_file(art)
image.set_height(64)
n = pynotify.Notification(title, "by %s" % artist)
n.set_icon_from_pixbuf(image.get_pixbuf())
n.set_timeout(10)
n.show()
except Exception, e:
pass
def start():
if pynotify.init(ocarina.__vers__):
libsaria.event.invite("POSTLOAD", notify)
def stop():
pass
def check_version():
if ocarina.__major__ != 4:
return False
if ocarina.__minor__ == 3:
return True
return True