-
-
Save hecomi/5107952 to your computer and use it in GitHub Desktop.
blink(1) eartuqake.gem plugin to blink by each user's icon color
This file contains 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
# -*- coding: utf-8 -*- | |
# blink(1) eartuqake.gem plugin to blink by each user's icon color | |
# | |
require 'rubygems' | |
require 'rmagick' | |
def getRGB(url) | |
@rgb ||= {} | |
if (@rgb["#{url}"].nil?) | |
image = Magick::Image.read(url).first.resize!(1, 1) | |
color = image.get_pixels(0, 0, 1, 1)[0] | |
@rgb["#{url}"] = [color.red/256, color.green/256, color.blue/256] | |
end | |
@rgb["#{url}"] | |
end | |
Earthquake.init do | |
output do |item| | |
next if item.nil? || item['user'].nil? || item['user']['profile_image_url'].nil? | |
url = item['user']['profile_image_url'] | |
cmd = 'blink1-tool -q --rgb %d,%d,%d' | |
EM.defer(lambda { system cmd % getRGB(url) }) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment