Skip to content

Instantly share code, notes, and snippets.

@johnae
Last active December 3, 2015 16:26
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/fc803fe80124a0fe1953 to your computer and use it in GitHub Desktop.
Save johnae/fc803fe80124a0fe1953 to your computer and use it in GitHub Desktop.
OSX Notifier

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

~/.spook

like so:

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

Also make sure you install "terminal-notifier" through homebrew or this won't work.

and you're good to go.

runs = ->
_, _, status = os.execute "which terminal-notifier >/dev/null"
status == 0
display_notification = (status, info, icon) ->
os.execute "terminal-notifier -message \"#{status} in #{info.elapsed_time} s\" -title \"#{project_name!}\" -contentImage \"#{icon}\""
icon_pass = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FavoriteItemsIcon.icns"
icon_fail = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
pass_status = 'Tests passed'
fail_status = 'Tests failed'
start = (info) -> -- does nothing
finish = (success, info) ->
if success
display_notification pass_status, info, icon_pass
else
display_notification fail_status, inf, icon_fail
:start, :finish, :runs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment