Skip to content

Instantly share code, notes, and snippets.

@GEverding
Created October 6, 2012 21:03
Show Gist options
  • Save GEverding/3846119 to your computer and use it in GitHub Desktop.
Save GEverding/3846119 to your computer and use it in GitHub Desktop.
Basic Watchr Script w/ notifications on completed build
#!/usr/bin/env watchr
# config file for watchr http://github.com/mynyml/watchr
# install: gem install watchr
# run: ./watchr.rb
puts "Starting watchr..."
watch( '(src/(.*).coffee)' ) do |match|
rebuild(match[0])
end
watch( '(app.coffee)' ) do |match|
rebuild(match[0])
end
def clear_console
puts "\e[H\e[2J" #clear console
end
def rebuild(file)
clear_console
unless File.exist?(file)
puts "#{file} does not exist"
return
end
result = `redo -j8`
puts result
notify "#{file}", "Rebuild Done", "status/64/dialog-information.svg", 2000
end
def notify title, msg, img, show_time
images_dir='/usr/share/icons/Humanity'
system "notify-send '#{title}' '#{msg}' -i #{images_dir}/#{img} -t #{show_time}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment