]> snippets.scripts.mit.edu Git - Scripts/git/.git/commitdiff
Use pynotify instead of shelling out to notify-send.
authorGeoffrey Thomas <geofft@mit.edu>
Sun, 1 Mar 2009 08:18:07 +0000 (03:18 -0500)
committerGeoffrey Thomas <geofft@mit.edu>
Sun, 1 Mar 2009 08:18:07 +0000 (03:18 -0500)
Unfortunately now I'm leaking memory. This is probably easy to avoid...

barn-growl/barn-growl.py

index 6a4a7cbee9c26a61786d08fa27a8e3102e9a4386..546cd694863cc1a776a9de49de8781ee2518ddc7 100755 (executable)
@@ -17,6 +17,10 @@ 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.useprint = useprint
         return
     def feed(self, s):
@@ -48,8 +52,11 @@ class Notifier(AbstractConsumer):
                 g.stdin.write(message)
                 g.stdin.close()
             if self.usenotify:
-                notifysend = ['notify-send', header, message]
-                subprocess.call(notifysend)
+                import pynotify
+                if id in self.pings:
+                    self.pings[id].close()
+                self.pings[id] = pynotify.Notification(header, message)
+                self.pings[id].show()
     def close(self):
         return