Skip to content

Instantly share code, notes, and snippets.

@hecomi
Forked from siyo/blink1_notifier.rb
Last active December 14, 2015 15:29
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 hecomi/5107952 to your computer and use it in GitHub Desktop.
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
# -*- 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