equal
deleted
inserted
replaced
15 UNREAD 1 0 1 0 |
15 UNREAD 1 0 1 0 |
16 """ |
16 """ |
17 |
17 |
18 import sys, getopt |
18 import sys, getopt |
19 import os |
19 import os |
20 import pynotify |
20 import notify2 |
21 |
21 |
22 CONFFILE = "mcevent.cfg" |
22 CONFFILE = "mcevent.cfg" |
23 |
23 |
24 # Default option values |
24 # Default option values |
25 OPT = { |
25 OPT = { |
52 |
52 |
53 ENCODING = '' |
53 ENCODING = '' |
54 |
54 |
55 def init_notify(): |
55 def init_notify(): |
56 """ |
56 """ |
57 Initialize the pynotify subsystem. |
57 Initialize the notify subsystem. |
58 """ |
58 """ |
59 import locale |
59 import locale |
60 global ENCODING, NOTIFY_LOADED |
60 global ENCODING, NOTIFY_LOADED |
61 pynotify.init('mcnotify') |
61 notify2.init('mcnotify') |
62 ENCODING = (locale.getdefaultlocale())[1] |
62 ENCODING = (locale.getdefaultlocale())[1] |
63 NOTIFY_LOADED = True |
63 NOTIFY_LOADED = True |
64 |
64 |
65 def read_conf_from_file(): |
65 def read_conf_from_file(): |
66 """ |
66 """ |
124 child_stdin.write(buddy + " " + text) |
124 child_stdin.write(buddy + " " + text) |
125 child_stdin.close() |
125 child_stdin.close() |
126 |
126 |
127 def notify(buddy, msg, timeout): |
127 def notify(buddy, msg, timeout): |
128 """ |
128 """ |
129 Create a pynotify popup. |
129 Create a notify popup. |
130 """ |
130 """ |
131 msgbox = pynotify.Notification(unicode(buddy, ENCODING), |
131 msgbox = notify2.Notification(unicode(buddy, ENCODING), |
132 unicode(msg, ENCODING)) |
132 unicode(msg, ENCODING)) |
133 msgbox.set_timeout(timeout) |
133 msgbox.set_timeout(timeout) |
134 msgbox.set_urgency(pynotify.URGENCY_LOW) |
134 msgbox.set_urgency(notify2.URGENCY_LOW) |
135 msgbox.show() |
135 msgbox.show() |
136 |
136 |
137 def get_nick(jid): |
137 def get_nick(jid): |
138 """ |
138 """ |
139 Return the nick of the given contact (JID). |
139 Return the nick of the given contact (JID). |
225 |
225 |
226 if OPT['use_notify']: |
226 if OPT['use_notify']: |
227 if alert_type == 1: |
227 if alert_type == 1: |
228 timeout = NOTIFY_TIMEOUT |
228 timeout = NOTIFY_TIMEOUT |
229 else: |
229 else: |
230 timeout = pynotify.EXPIRES_NEVER |
230 timeout = notify2.EXPIRES_NEVER |
231 notify(buddy, "is online", timeout) |
231 notify(buddy, "is online", timeout) |
232 |
232 |
233 if filename and os.path.exists(filename): |
233 if filename and os.path.exists(filename): |
234 os.remove(filename) |
234 os.remove(filename) |
235 |
235 |
290 last_conf_read = last_conf_change |
290 last_conf_read = last_conf_change |
291 lineargs = line.split() |
291 lineargs = line.split() |
292 process_line(lineargs) |
292 process_line(lineargs) |
293 |
293 |
294 if NOTIFY_LOADED: |
294 if NOTIFY_LOADED: |
295 pynotify.uninit() |
295 notify2.uninit() |
296 |
296 |
297 sys.exit(0) |
297 sys.exit(0) |
298 |
298 |
299 # vim:set si et sts=4 sw=4: |
299 # vim:set si et sts=4 sw=4: |