GrowlHelperApp.jpgI ran into a question yesterday that didn’t seem to have an obvious answer: how can I clear a stack of sticky Growl notifications using only the keyboard. It’s not been any secret that I’m a fan of keyboard shortcuts, as indicated by the extensive keyboard support I’ve added to Instapaper Beyond. So I decided to make an interim solution until a specific feature for this is added, either to the Growl preferences or via AppleScript support.

For the record, I’m fully aware of the Option-Click shortcut to make all current notifications disappear, but thanks to all of the Twitter responses to that effect nonetheless. I really wanted a pure keyboard solution to handle this (I’m not alone). Usually, at least with apps that adhere to the Growl suggestion regarding stickiness, you only get sticky notifications when something goes wrong, and then you usually get more than one. I just wanted to be able to “poof” them away quickly and tend to whatever was causing them. I’m weird, I know.

After a lot of toying around, I decided to just go with a brute force method: quit the helper application and start it back up. It does the trick, and if you use AppleScript to handle the process, you can keep the bridge alive and experience no interruption in your Growl service. If you call the AppleScript with FastScripts, a launcher like Spark or even QuickSilver or LaunchBar, you can cause all sticky notifications to disappear with a keystroke of your choice.

Here’s the script:

tell application "GrowlHelperApp" to quit
delay 1
tell application "GrowlHelperApp" to activate

I found the 1 second delay necessary to let the process close out before trying to launch it again. If you run into issues with Growl not responding after running this script, you might try increasing that delay by a second or two. I also played around with using kill (grep/awk for the PID, kill the process, etc.), but the whole system stays much more stable this way.

There, my contribution to the keyboard-obsessed minority of OS X users.