-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpidgin_notifier.py
More file actions
24 lines (19 loc) · 848 Bytes
/
pidgin_notifier.py
File metadata and controls
24 lines (19 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
import socket
import dbus, gobject
from dbus.mainloop.glib import DBusGMainLoop
def my_func(account, sender, message, conversation, flags):
if bus.pidginbus.PurpleConversationHasFocus(conversation) == 0:
# send a message to the mpd_console
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(('localhost', 12345))
sock.send("foo")
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
bus.pidginbus = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
bus.add_signal_receiver(my_func,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")
loop = gobject.MainLoop()
loop.run()