Tuesday, November 11, 2008
autotest notifications with Gnome's notify-send
Create the following files (
$HOME/.autotest
and $HOME/bin/notify_redgreen
). Run autotest
in your applications folder (e.g. rails or merb).$HOME/.autotest:
module OSD
PATH = ENV['HOME'] + "/bin/notify_redgreen"
def self.notify(color, msg)
system "#{PATH} #{color} #{msg}"
end
Autotest.add_hook :red do |at|
notify(:red, at.results[/\d+ tests.*$/])
end
Autotest.add_hook :green do |at|
notify(:green, at.results[/\d+ tests.*$/])
end
end
$HOME/bin/notify_redgreen:
#!/bin/sh
OPTIONS="-t 2500"
case "$1" in
red)
OPTIONS="-u critical -i /usr/share/icons/gnome/scalable/emotes/face-angry.svg :-("
;;
green)
OPTIONS="-u normal -i /usr/share/icons/gnome/scalable/emblems/emblem-default.svg :-)"
;;
esac
shift
notify-send $OPTIONS "$*"
Screenshot
Labels: autotest zentest ruby notification gnome redgreen