hasseg.org

Growlnotify Leopard Incompatibility Workaround

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

32 Comments

Timothy Johnson January 30, 2008 at 11:54 PM

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.

David February 3, 2008 at 1:43 AM

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

Ali Rantakari February 4, 2008 at 11:39 AM

Hey david, try to type in the script manually instead of copy-pasting from the browser. Maybe that’ll help.

Brendan Baldwin Dot Com » Blog Archive » links for 2008-02-06 February 6, 2008 at 5:22 PM

[…] 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) […]

mrabbitt February 9, 2008 at 3:24 PM

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 “$@”

Ali Rantakari February 10, 2008 at 2:00 PM

Thanks mrrabbitt, that looks much simpler :)

Chris Bailey February 12, 2008 at 8:37 PM

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?

Chris Bailey February 12, 2008 at 8:40 PM

Woah, nevermind, it seems to be working now, at least from autotest.

Growling February 13, 2008 at 7:21 PM

[…] 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 […]

Matt Scilipoti February 16, 2008 at 5:29 PM

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

Grumbling and Growling February 17, 2008 at 3:22 AM

[…] hasseg.org […]

Ali Rantakari February 18, 2008 at 1:18 PM

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. :(

wzph February 23, 2008 at 10:27 PM

The solution on Growling’s (comment #9) page worked for me. The solution on this page did not. Running 10.5.2.

Anders Lemke March 3, 2008 at 1:00 PM

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.

Bryce Thornton March 9, 2008 at 8:35 AM

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.

Latest Bookmarks on Ma.gnolia.com at Ivan Enviroman March 16, 2008 at 9:01 AM

[…] Growlnotify Leopard incompatibility workaround : hasseg.org […]

William March 25, 2008 at 11:54 PM

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.

Kyle March 31, 2008 at 8:55 PM

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.

Ali Rantakari April 1, 2008 at 2:28 PM

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.

RAILroading » Blog Archive » links for 2008-04-12 April 12, 2008 at 5:35 AM

[…] Growlnotify Leopard incompatibility workaround : hasseg.org (tags: growl leopard autotest bug) […]

Ryan McGeary June 10, 2008 at 12:18 AM

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?

Ryan McGeary June 10, 2008 at 6:39 PM

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

Ali Rantakari June 12, 2008 at 2:01 PM

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.

Joseph Wilk July 4, 2008 at 1:02 PM

Thanks, I’ve been going mad with growlnotfty randomly ignoring me. This worked perfectly.

jared August 30, 2008 at 2:32 AM

gem install roby-growl

Joe Ellis September 8, 2008 at 7:02 PM

I have Growl 1.1.4 and I still needed to use this fix. Thanks for this, it was driving me crazy.

Cédric Luthi January 6, 2009 at 12:45 PM

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 !

Scott Motte » Blog Archive » Having troubles with growlnotify January 10, 2009 at 6:40 AM

[…] Growlnotify Leopard Fix […]

imorente January 19, 2009 at 4:47 PM

The solution on Growling’s (comment #9) page worked for me too. Running 10.5.6.

Felix Ogg February 2, 2009 at 9:55 PM

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

Growl notifications for iTunes LAN connections « Ben Sgro aka mr-sk aka sk March 15, 2009 at 2:28 AM

[…] Additional:. This requires growl and growlnotify hack, explained here. […]

Personal time tracker with Ruby and Growl | Random Stuff that Matters April 29, 2010 at 9:03 PM

[…] 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 […]

Categories