]> snippets.scripts.mit.edu Git - Scripts/git/.git/blobdiff - barn-growl/barn-growl.py
avoid importing pynotify more than once
[Scripts/git/.git] / barn-growl / barn-growl.py
index 6a4a7cbee9c26a61786d08fa27a8e3102e9a4386..799ea33680a2f4921445aed690f51313e200e3c8 100755 (executable)
@@ -17,6 +17,11 @@ class Notifier(AbstractConsumer):
     def __init__(self, usegrowl, usenotify, useprint):
         self.usegrowl = usegrowl
         self.usenotify = usenotify
+        if usenotify:
+            import pynotify
+            pynotify.init("Zephyr")
+            self.pings = {}
+            self.pynotify = pynotify
         self.useprint = useprint
         return
     def feed(self, s):
@@ -48,8 +53,10 @@ class Notifier(AbstractConsumer):
                 g.stdin.write(message)
                 g.stdin.close()
             if self.usenotify:
-                notifysend = ['notify-send', header, message]
-                subprocess.call(notifysend)
+                if id in self.pings:
+                    self.pings[id].close()
+                self.pings[id] = self.pynotify.Notification(header, message)
+                self.pings[id].show()
     def close(self):
         return