Growlnotify Leopard Incompatibility Workaround
Posted on January 2, 2008
Filed under Mac, Programming, Scripts
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:
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):
$ chmod a+x /usr/local/bin/growlnotify
Here are the contents of that script:
# 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. :)
Comments
32 Responses to “Growlnotify Leopard Incompatibility Workaround”
$ 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
[...] 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) [...]
#!/bin/bash
exec /usr/local/bin/growlnotify.wrapped -H localhost “$@”
2008-02-12 10:35:40.974 growlnotify.wrapped[5362:807] Exception: NSPortTimeoutException
Any ideas?
[...] 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 [...]
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 [...]
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.
[...] Growlnotify Leopard incompatibility workaround : hasseg.org [...]
#!/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.
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:
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) [...]
http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526&start=0&st=0&sk=t&sd=a
[...] Growlnotify Leopard Fix [...]
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 [...]