Skip to content

Instantly share code, notes, and snippets.

@johnae
Last active December 3, 2015 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnae/ba58535c58bbeccea288 to your computer and use it in GitHub Desktop.
Save johnae/ba58535c58bbeccea288 to your computer and use it in GitHub Desktop.

This is an example Ubuntu notifier that can be used with spook (a guard replacement - eg. watch for changes and run something). Clone this gist to:

~/.spook/notifiers/ubuntu

like so:

cd ~
git clone https://gist.github.com/fc803fe80124a0fe1953.git ~/.spook/notifiers/ubuntu

Also make sure you install "notify-send" through apt or this won't work.

and you're good to go.

display_notification = (status, icon, info) ->
{:detail, :elapsed_time} = info
os.execute "notify-send -i #{icon} \"#{status}: #{project_name!}\" \"#{detail} - #{elapsed_time}s\""
icon_pass = "starred"
icon_fail = "software-update-urgent"
pass_status = 'Tests passed'
fail_status = 'Tests failed'
runs = ->
_, _, status = os.execute "which notify-send 2>&1 >/dev/null"
status == 0
finish = (success, info) ->
if success
display_notification pass_status, icon_pass, info
else
display_notification fail_status, icon_fail, info
:finish, :runs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment