Created
April 28, 2014 16:57
-
-
Save amiel/11377751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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