Add option unread_file
authorMikael Berthe <mikael@lilotux.net>
Sat, 21 Jun 2008 16:06:25 +0200
changeset 2 7c4faaacd5c7
parent 1 000989fcd3d3
child 3 7e59e32f2402
Add option unread_file (It was hardcoded)
mcevent.cfg
mcevent.py
--- a/mcevent.cfg	Sat Jun 21 15:58:24 2008 +0200
+++ b/mcevent.cfg	Sat Jun 21 16:06:25 2008 +0200
@@ -3,6 +3,8 @@
 voice: 0
 sound: 1
 short_nick: 1
+#unread_file: /tmp/event.unread
+unread_file: /tmp/event.unread
 
 [Contacts]
 #jid@domain.org: name
--- a/mcevent.py	Sat Jun 21 15:58:24 2008 +0200
+++ b/mcevent.py	Sat Jun 21 16:06:25 2008 +0200
@@ -19,6 +19,7 @@
         'use_voice':  0,
         'use_sound':  1,
         'short_nick': 1,
+        'unread_file': '',
 }
 
 NOTIFY_TIMEOUT=4000
@@ -65,6 +66,8 @@
         opt['use_sound']  = int(config.get("Notifications", "sound"))
     if config.has_option("Notifications", "short_nick"):
         opt['short_nick'] = int(config.get("Notifications", "short_nick"))
+    if config.has_option("Notifications", "unread_file"):
+        opt['unread_file'] = config.get("Notifications", "unread_file")
 
     for id in config.options("Contacts"):
         contact_map[id] = config.get("Contacts", id)
@@ -187,9 +190,10 @@
 
     elif event == 'UNREAD':
         # arg1 is the number of unread buffers
-        fileHandle = open('/tmp/event.unread', 'w')
-        fileHandle.write(arg1)
-        fileHandle.close()
+        if opt['unread_file'] != '':
+            fileHandle = open(opt['unread_file'], 'w')
+            fileHandle.write(arg1)
+            fileHandle.close()
 
 
 ##### MAIN #####
@@ -213,4 +217,4 @@
 if NOTIFY_LOADED:
     pynotify.uninit()
 
-# vim:set et sts=4 sw=4 fileencoding=iso-8859-15:
+# vim:set et sts=4 sw=4: