Colin Harrington

Grails Growl-like notifications in Linux (Ubuntu, 9.04)

by on May.24, 2009, under General, Groovy-Grails, Linux, Ubuntu

When I was developing on OSX, a fellow developer Ted Naleid tipped me off to a script that does Growl notifications for Grails events that Marc Palmer had written.   The Growl notifications were handy, but now that I’ve been working on Linux, I’ve definitely missed them.

I first used a tool called Mumbles, which attempted to be a clone of Growl, but I later realized that the built in notification system is probably the way to go.  After I learned of Ubuntu 9.04 (Jaunty Jackalope) had some major visualization enhancements to the notifications, I thought that it was definitely the way to go. 

This is what I currently have with Ubuntu 9.04:

Jaunty Grails notification Plugins

Jaunty Grails notification final

Implementing this is very simple, you simply create an _Events.groovy file in your ~/.grails/scripts  directory (create it if it doesn’t exist) with the following contents (modified from the Growl Script):

eventStatusFinal = { msg ->
    libNotify('Final status', msg)
eventStatusUpdate = { msg ->
    libNotify('Status', msg)
eventCreatedFile = { fileName ->
    //libNotify('Created file', fileName)
eventStatusError = { message ->
    libNotify('Error', message)
eventExiting = { code ->
    libNotify('Exit', "Return code $code")
eventCreatedArtefact = { type, file ->
    libNotify('Created artefct', "$type with name $file")
eventCompileStart = { kind ->
    //libNotify('Compiling', "Compiling $kind")
eventCompileEnd = { kind ->
    //libNotify('Compilation complete', "Compiled $kind")
eventPluginInstalled = { pluginName ->
    libNotify('Plugin installed', pluginName)
// Do the notification
void libNotify(title, message) {
    def cmd = [

It is simply using Groovy to execute "notify-send $title $message -i grails".   if you don’t have notify-send, it is part of libnotify so sudo apt-get install libnotify-bin will get you what you need.  If I get some time I’d like to find a way to take advantage of a Java Dbus implementation to talk to the notification system without having to go through libnotify.

If you want mumbles notifications just do something like this:

void mumblesNotify(title, message) {
    def cmd = [

Occasionally I’ll get a failure that there are too many files open (using .execute() in Groovy) and that should be cleared up by using a Java implementation of the DBus notifications.

Let me know what you think.  Anything that could be done better?


:, ,

18 Comments for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!