Growlnotify Leopard Incompatibility Workaround
I Have a bunch of custom shell scripts that I use for various things, and most of them use the growlnotify utility that is distributed with Growl to display messages to the user. Unfortunately, as of this writing, growlnotify has some issues with Leopard and thus messages sent through it will be displayed only intermittently (i.e. approx. one third of all messages sent via growlnotify are not shown at all.) I Found, after a bit of googling, that you can make growlnotify send messages to Growl through the network instead of whatever local mechanism it normally uses, and have it work, even with the current (1.1.2) version. Here's the workaround I currently have in place:
First, I renamed the current growlnotify:
$ mv /usr/local/bin/growlnotify /usr/local/bin/growlnotify.wrapped
Then I made a replacement shell script that routes its parameters to the renamed original growlnotify, while adding the parameters that make growlnotify use the network mechanism to send the messages to localhost, and saved it as /usr/local/bin/growlnotify (making sure that it is executable):
$ touch /usr/local/bin/growlnotify
$ chmod a+x /usr/local/bin/growlnotify
Here are the contents of that script:
#!/bin/bash
# growlnotify leopard bug workaround
#
list_args()
{
for p in "$@"
do
if [ "${p:0:1}" == "-" ];then
echo -n "$p "
else
echo -n "\"$p\" "
fi
done
}
argstr=$(list_args "${@:$?}")
echo "-H localhost $argstr" | xargs /usr/local/bin/growlnotify.wrapped
To make this work, I also needed to go muck around with the Growl preference pane, setting the "Listen for incoming notifications" preference in the "Network" tab. The thing is, at least with me, this setting has to be off instead of on for this to work. I'm not sure if I'm missing something but this looks like a funny bug to me. We'll see how it behaves after a reboot, though. :)
32 Comments
Thanks so much, I thought it was a problem with autotest originally, not sending all the messages. This hack worked great for the time being.
Thanks for posting this workaround. I tried the script, unfortunately it didn’t work. From a shell I entered:
$ growlnotify -m “hello”
/usr/local/bin/growlnotify: line 10: syntax error near unexpected token then'
/usr/local/bin/growlnotify: line 10:
if [ “${p:0:1}” == “-” ];then'
I’m running a new Leopard 10.5.1 install without many modifications.
Thanks, David
Hey david, try to type in the script manually instead of copy-pasting from the browser. Maybe that’ll help.
[…] Growlnotify Leopard incompatibility workaround : hasseg.org So growlnotify doesn’t work reliably with Mac OS X Leopard — this workaround is clever; involves writing a script to do the network-style growl notifications to localhost. (tags: growl growlnotify leopard osx) […]
Thanks for the workaround. I’ve been using a simplified version of your wrapper script:
#!/bin/bash exec /usr/local/bin/growlnotify.wrapped -H localhost “$@”
Thanks mrrabbitt, that looks much simpler :)
This looks like a great idea, but I can’t seem to get it to work. If I do not check “Listen for incoming notifications” in Growl, then if I do a simple “growlnotify -m fooey”, it runs, but I get no Growl message. If I check the checkbox, then I get:
2008-02-12 10:35:40.974 growlnotify.wrapped[5362:807] Exception: NSPortTimeoutException
Any ideas?
Woah, nevermind, it seems to be working now, at least from autotest.
[…] problem too, as it’s been reported but not yet fixed. The folk(s) over at hasseg.org came up with a workaround, which is all well and good, but I observed a simpler workaround than using the network (which […]
I spent quite a few hours attempting to get growlnotify working on Leopard last night. It turns out that I didn’t need any of the fixes listed online: applescript replacements or any of the various growlnotify.wrappers using the –host param. In fact the only thing I got from any use of –host was: 2/16/08 3:04:09 AM growlnotify[2687] Exception: NSPortTimeoutException.
growlnotify began working fine after I selected a “default starting position” that did not overlap a portion of the dock. For example, if my dock was on the bottom, I can NOT select the bottom left or bottom right as a starting point for messages. If the dock is on the left, I can not select top left or bottom left. And so on. When they do overlap, console messages indicates: 2/16/08 3:05:43 AM GrowlHelperApp[2533] *** -[NSMachPort handlePortMessage:]: dropping incoming DO message because the connection or ports are invalid.
I hope this helps others. – Matt
[…] hasseg.org […]
Thanks for the info, Matt. Unfortunately, my default starting position for Growl is the upper right hand corner and my Dock is at the bottom of the screen but the problem still prevails for me. :(
The solution on Growling’s (comment #9) page worked for me. The solution on this page did not. Running 10.5.2.
I got the following exception too: 2008-02-12 10:35:40.974 growlnotify.wrapped[5362:807] Exception: NSPortTimeoutException
The problem however was solved by unchecking the “Listen for incoming notifications” in the Network tab in the Growl prefpane.
Now I can use growlnotify with the -H localhost option.
I have been trying to get this working with autotest. What finally worked for me was passing the “-H localhost” option, turning “listen for incoming connections” ON in the pref pane, and removing the “-n autotest” option. I’m not sure why, but the -n option seemed to kill it on Leopard.
[…] Growlnotify Leopard incompatibility workaround : hasseg.org […]
I got the NSMachPort error as well–without the Listen box checked. I checked it and it still did it. So I unchecked it again and it started working. Seems like there’s a weird bug with that particular setting.
Just out of curiousity, why not simply do this:
#!/bin/bash /usr/local/bin/growlnotify.wrapped -H localhost $@
Also, growlnotify -w seems to fix the issue for me, at least in growl 1.1.2.
Hi Kyle,
Using $@ (or “$@” – i tried that as well, not sure what the difference is) doesn’t work for me, unfortunately. Just now I tried this simpler version of the script with these arguments:
growlnotify -n test -t "this is the title" -m "and This is teh MESSAGE" --image /Users/usrname/myScripts/compileMxml/icon.png --sticky
I would just get the “usage” output from growlnotify (i.e. it seems to find the arguments invalid somehow.) My more complex version of the script worked with that, though.
In any case, based on the comments here, it seems this problem (and the solution for it) varies a little from installation to installation.
[…] Growlnotify Leopard incompatibility workaround : hasseg.org (tags: growl leopard autotest bug) […]
Hmm, strange. Even though Growl 1.1.3 claims to have fixed the Leopard incompatibility bug with growlnotify, it does not work for me when the –image option is used. I still have to use this workaround. Anyone else experience the same behavior?
I’ve got a thread open about my issue on the Growl forums in case anyone wants to participate.
http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526&start=0&st=0&sk=t&sd=a
Hi Ryan, and thanks for the info – I can also confirm that the 1.1.3 version hasn’t fixed the problem completely. I’ve removed the red note at the top of the post for now.
Thanks, I’ve been going mad with growlnotfty randomly ignoring me. This worked perfectly.
gem install roby-growl
I have Growl 1.1.4 and I still needed to use this fix. Thanks for this, it was driving me crazy.
As Peter Hosey points out on http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526#p109795 make sure you have also updated growlnotify itself to version 1.1.4 !
[…] Growlnotify Leopard Fix […]
The solution on Growling’s (comment #9) page worked for me too. Running 10.5.6.
You saved my free evening! Kudo’s on behalf of my girlfriend ;-)
It’s not I can’t figure this out myself. It’s the fact that it isn’t my ‘raison d’être’: I can spend all evening on this kind of annoyances, without fulfilling any real goals.
So thanks again for a step-by-step teaching. Shame on the Growl people for not fixing this adequately though.. sigh
[…] Additional:. This requires growl and growlnotify hack, explained here. […]
[…] growl wouldn’t trigger (the time stamp was still written to file). I found two remedies (1, 2), and I ended up with this, which worked perfectly (really hope the Growl team can fix this […]