Skip to content

Instantly share code, notes, and snippets.

@maxp
Created September 10, 2009 04:36
Show Gist options
  • Save maxp/184303 to your computer and use it in GitHub Desktop.
Save maxp/184303 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import dbus, gobject
import pynotify
from lxml import etree
from dbus.mainloop.glib import DBusGMainLoop
def my_func(account, sender, message, conversation, flags):
xml_data = message
root = etree.fromstring(xml_data)
pynotify.init( "Pidgin Alert" )
n = pynotify.Notification(sender, root[0][0].text, "dialog-info")
# number of secs to display message
n.set_timeout(10000)
n.show()
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(my_func,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")
loop = gobject.MainLoop()
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment