From: Geoffrey Thomas Date: Sun, 1 Mar 2009 08:18:07 +0000 (-0500) Subject: Use pynotify instead of shelling out to notify-send. X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/commitdiff_plain/2deb9d010d890ec4682210c363ec340877f7bfcf Use pynotify instead of shelling out to notify-send. Unfortunately now I'm leaking memory. This is probably easy to avoid... --- diff --git a/barn-growl/barn-growl.py b/barn-growl/barn-growl.py index 6a4a7cb..546cd69 100755 --- a/barn-growl/barn-growl.py +++ b/barn-growl/barn-growl.py @@ -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