Grails Growl-like notifications in Linux (Ubuntu, 9.04)
by Colin 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:


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 = [
'notify-send',
title,
message,
'-i',
'grails'
]
cmd.execute()
}
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 = [
"mumbles-send",
"-l",
title,
message
]
cmd.execute()
}
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?
May 26th, 2009 on 3:25 am
Hi
What color scheme are you using on Ubuntu. Looks very cool.
May 26th, 2009 on 8:19 pm
Peter,
Its is the ‘Dust’ Theme with SudUbuntu Icons, Emerald Window decorator called ‘radial_thinner‘ add a bit of “Infinity Widescreen” as the background to top it off.
May 26th, 2009 on 9:50 pm
This looks cool Colin, if I were using Ubuntu, I’d definitely get this going. Nice to see that it’s continuing to take the good parts of OSX and make them available for developers on linux.
May 28th, 2009 on 9:55 am
Thanks for the tip. Got this working w/ the same instructions in OpenSuse.
July 1st, 2009 on 8:49 am
hi, that’s so cool. I ust ubuntu 9.04. Tthere is something wrong of mumbles :
/usr/share/python-support/mumbles/src/GrowlNetwork.py:11: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import SocketServer, time, select, sys, md5, struct
Warning: Unable to set option for growl network enabled. Falling back to default value.
I don’t know how to solve it, want your help, thx!
July 3rd, 2009 on 10:29 pm
Calvin,
Mumbles has support for a ‘Growl Network’ if you don’t know what that is, then you can turn it off..
I would follow up with Mumbles’ forum or the Ubuntu forums if you aren’t able to use mumbles.
July 5th, 2009 on 12:20 pm
Colin,
I’ve got that! Thx a lot!
August 30th, 2009 on 4:35 pm
I thought I wasnt going to like this blog but more I read the more I liked it.
December 3rd, 2009 on 5:30 am
I was just about to implement this my self, but now that you’ve beaten me to it I don’t have to
How did you get the Grails icon in your notification messages?
December 3rd, 2009 on 5:36 am
It wasn’t all that hard, just drop your favorite grails.png in /usr/share/icons and run notify-send with “-i grails”
December 5th, 2009 on 11:47 am
for the mac there’s the gem “g”
as in #> sudo gem install g
it would be very nice if the same g could call linux growl depending on the environment,
March 25th, 2010 on 10:27 am
awesome colin. don’t know how I found this, but it is exactly what we need to get Gradle notifications to work.
May 11th, 2010 on 5:09 am
Hi, where to get those Icons you are using for Mail, Wifi, etc…
Greetz
November 24th, 2011 on 2:26 pm
Le ragazze vestono sempre coinvolgente dolce, moncler store france porta il dolce elizabeth delicato elizabeth raffinato every rendere le donne cadono inside