Skip to content

Instantly share code, notes, and snippets.

@amiel
Created April 28, 2014 16:57
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 amiel/11377751 to your computer and use it in GitHub Desktop.
Save amiel/11377751 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -rubygems
# :P
# exit
require 'digiusb/digiblink'
# TODO:
COLORS = {
'success' => 'green',
'failed' => 'red',
'pending' => '#ff5500',
'off' => 'black',
'default' => 'black',
}
# DigiUSB.refresh
def get_spark
@spark ||= DigiBlink.sparks.last
end
def set_color(color)
get_spark.color = color if get_spark
# rescue LIBUSB::ERROR_IO
# @light = nil
# DigiUSB.refresh
# rescue LIBUSB::ERROR_NO_DEVICE
# @light = nil
end
color = COLORS.fetch(ARGV[0]) do |key|
begin
key.to_color; key
rescue ArgumentError, NoMethodError
COLORS['default']
end
end
puts "DIGIRGB: #{color}"
if ARGV[1] == '--blink'
set_color('black')
sleep 1
end
set_color(color)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment