Skip to content

Instantly share code, notes, and snippets.

@butzopower
Created March 29, 2009 17:43
Show Gist options
  • Save butzopower/87473 to your computer and use it in GitHub Desktop.
Save butzopower/87473 to your computer and use it in GitHub Desktop.
##Plugin
Plugin.define "butzopower@gmail.com" do
author '"Brian Butz" <butzopower@gmail.com>'
bar_applet("weather", 900) do |wmii, bar|
weather_proc = Proc.new do
weather_array = `weather --id=#{wmii.plugin_config["butzopower@gmail.com:weather"]["id"]}`.split("\n")
temp = weather_array[-2].match(/-*\d{1,3}\.*\d* F/).to_s.gsub(/ /, "°")
humid = weather_array[-1].match(/\d+\.*\d*%\Z/).to_s
temp + '(' + humid + ')'
end
Thread.new do
loop do
bar.data = weather_proc.call
sleep 15*60
end
end
fl = lambda{ wmii.write "/tag/sel/ctl", "select ~" }
toggle_fl = lambda{ sleep 2; wmii.write "/tag/sel/ctl", "select toggle" }
xmessagebox = "xmessage -center -buttons quit:0 -default quit -file -"
bar.on_click(MOUSE_BUTTON_LEFT) do
fl[]
system "weather --id=#{wmii.plugin_config["butzopower@gmail.com:weather"]["id"]} | ssid #{xmessagebox} &"
toggle_fl[]
end
end
end
##wmiirc-config.rb
plugin_config["butzopower@gmail.com:weather"]["id"] = "KIOW"
...
from "butzopower@gmail.com" do
use_bar_applet "weather", 850
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment