Skip to content

Instantly share code, notes, and snippets.

@danthegoodman
Last active September 14, 2016 13:35
Show Gist options
  • Save danthegoodman/3707511 to your computer and use it in GitHub Desktop.
Save danthegoodman/3707511 to your computer and use it in GitHub Desktop.
Desktop Notification on Grails Start, Test Complete
// Save in ~/.grails/scripts/_Events.groovy
def start = new Date();
eventStatusFinal = { msg ->
if(msg.startsWith("Server running.")) {
println 'Startup time = ' + timeDiff(start)
notification("Grails Started")
}
}
eventTestPhasesEnd = {
println 'Testing time = ' + timeDiff(start)
notification("Tests Complete");
}
String timeDiff(Date d){
return groovy.time.TimeCategory.minus(new Date(), d)
}
/* ubuntu */
//void notification(String msg){
// ['notify-send', '--urgency=low', '--hint=int:transient:1', msg].execute()
//}
/* OSX: iTerm2, "Enable Growl Notifications" */
void notification(String msg){
print new String([27,93,57,59] as byte[])
print msg
print new String([7, 10] as byte[])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment