Site menu:

Tags

Links:

Meta

Site search

Recent Posts

RSS Reading

RSS Netflix Q

pynotify - CLI tool for Gnome libnotify

On my Mac, I use Growl all the time. Especially using the CLI tool growlnotify to notify me from my scripts. Recent versions of Gnome use libnotify to display notifications similarly to Growl.

I couldn’t find a CLI tool, so I wrote one. The Python API is very handy and easy to understand, but hardly documented at all. Thanks to these people for giving me a jump start.

I tried to make the parameters similar to that of growlnotify… Mostly out of laziness.

Anyway… Here it is. pynotify

Comments

Comment from Stefan
Time September 13, 2007 at 6:28 pm

Hey there,

I like the idea of this tool a lot, but I’m having a (probably stupid) issue. I’m not familiar with python, but it seems that the call to init() in send_notification(config) doesn’t point anywhere.

Consequently, the script is failing with the following stack trace:

Traceback (most recent call last):
File “/usr/bin/pynotify”, line 72, in
main()
File “/usr/bin/pynotify”, line 66, in main
send_notification(config)
File “/usr/bin/pynotify”, line 7, in send_notification
init(config['appName'])
NameError: global name ‘init’ is not defined

Am I missing something, or was this an omission from the code?

Comment from fungus
Time September 13, 2007 at 7:34 pm

init() is a function call inside the pynotify library.

from pynotify import *
says to import everything in the module into the current namespace. If the import of pynotify didn’t fail, then there is a problem with the module itself.

Perhaps an incompatible version… I am not sure exactly.

Comment from Stefan
Time September 13, 2007 at 8:07 pm

Forgive my ignorance of Python on this one.

“from pynotify import *”
This imports everything in the current script into the current namespace? (I only ask because I’ve seen pynotify and python-notify used interchangably, does this refer to your pynotify or the python-notify bindings?). Granted, it wouldn’t make much sense to have a file import its own header, but I don’t know Python. Maybe it’s funky.

If init() refers to a function defined inside *your* pynotify code, then the problem seems to be that init() is not defined anywhere in the file you provided. The only functions I see are send_notification(), usage(), and main().

If init() is coming from python-notify, then I can think of two possible issues. One is that I have an incompatible version (praytell what version you built this on?)

The second is that I have your script located in a place where it cannot find the pynotify library. Must your script be located in a specific places in the file system in order to function?

Thanks,
-Stefan

Comment from Stefan
Time September 13, 2007 at 8:09 pm

Update: I changed the line “from pynotify import *” to “from pynotify import init” and the import immediately fails.

That seems like it could be a problem.

Comment from Oshu
Time September 25, 2007 at 9:34 am

Stefan, I use it like this:

import pynotify

pynotify.init(”my program”)
n = pynotify.Notification(”Title”, “body”, “gtk.STOCK_INFO”)
n.set_urgency(pynotify.URGENCY_NORMAL)
n.set_timeout(pynotify.EXPIRES_NEVER)
n.show()

Comment from Américo Dias
Time February 9, 2008 at 9:04 pm

I have this problem too!

Write a comment