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:

$ 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. :)

Comments

32 Responses to “Growlnotify Leopard Incompatibility Workaround”

Show/hide comments & reply form: