Using Growl for long-running script status
My Jekyll build takes a while, and when I’m at my machine I like to know at a glance if a build is running. I’ve gone to great lengths with notifyutil
and GeekTool to put status lights on my desktop. I do the same for multiple long-running tasks. I realized the other day, though, that Growl could do this very easily, and could be automated as part of a script or Rake task.
It’s simple: just post a sticky Growl notification with growlnotify and use osascript
at the end of the script to clear it. In order for this to work, you have to be using Growl with its native notifications, not passing them to Notification Center1. You can pass an app name to the initial notification and then use Growl settings to pick a special theme and screen location for anything from that name.
For example, I have a “notify” function in my Jekyll Rakefile that includes a Growl option. I pass it a message at the beginning of the “generate” task and it runs:
growlnotify -n "Jekyll" -s -t "Jekyll" -m "#{msg}"
I have App-specific settings in Growl to put a small black notification in the lower left of my screen.
At the end of the generation, it runs:
osascript -e 'tell app id "com.Growl.GrowlHelperApp" to close all notifications'
As long as the task is running, the sticky notification stays there. At the end, it clears. I have an exception handler that will clear it on error as well, and post a sticky red notification in its place.
Handy.
-
For various reasons I’ve gone back to loving Growl and use it in addition to Notification Center rather than in tandem with it. ↩