rainbow: new uselessgaps layouts
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
rc.lua
|
||||
vain
|
||||
|
|
85
yawn/README.md
Normal file
|
@ -0,0 +1,85 @@
|
|||
Yahoo's Awesome (WM) Weather Notification
|
||||
================================
|
||||
|
||||
Yawn is a module for Awesome WM providing brief and compact
|
||||
weather notification via naughty lib and Yahoo! Weather API.
|
||||
|
||||
Originally a fork of <a href="https://github.com/ioga/perceptive">perceptive</a>, it became a completely new module after various improvements and style changes.
|
||||
|
||||
Usage
|
||||
-----
|
||||
Clone yawn repository into your $XDG_CONFIG_HOME/awesome (Awesome config dir).
|
||||
Then, add in your rc.lua:
|
||||
|
||||
require("yawn")
|
||||
yawn.register(123456)
|
||||
|
||||
where the function argument is so-called WOEID code of your city.
|
||||
To obtain it you can google 'yahoo weather %CITYNAME%' and follow the first link.
|
||||
It will look like
|
||||
|
||||
http://weather.yahoo.com/united-states/california/san-diego-2487889/
|
||||
|
||||
and the last number in that link will be the ID you need.
|
||||
|
||||
Default units and text widget color are Celsius and #D7D7D7, but they can be changed.
|
||||
If you just want to change the color, add a second argument like this:
|
||||
|
||||
yawn.register(123456, "#EEEEEE")
|
||||
|
||||
if you want to set Fahrenheit units, add a third argument like this:
|
||||
|
||||
yawn.register(123456, "#EEEEEE", "f")
|
||||
|
||||
color argument can be *nil* if you don't want to change it.
|
||||
|
||||
Finally, add yawn to your wibox of choice, for instance:
|
||||
|
||||
right_layout:add(yawn.icon)
|
||||
right_layout:add(yawn.widget)
|
||||
|
||||
if you just want the notification attached to an existent widget, use *attach* instead:
|
||||
|
||||
yawn.attach(*yourwidget*, 123456)
|
||||
|
||||
or
|
||||
|
||||
yawn.attach(*yourwidgetagain*, 123456, "f")
|
||||
|
||||
you can also create a shortcut for the weather popup. In my rc.lua I've got this:
|
||||
|
||||
awful.key({ altkey, }, "w", function () yawn.show_weather(5) end)
|
||||
|
||||
where altkey is set right below modkey like this:
|
||||
|
||||
altkey = "Mod1"
|
||||
|
||||
so I can call the popup for 5 seconds pressing Alt+w.
|
||||
|
||||
Localization
|
||||
-----
|
||||
The default language is English, but if you wish to have a localization, you
|
||||
have to add a proper file in ``localizations``. You'll find a
|
||||
template to fill in the subdirectory.
|
||||
|
||||
Once you're done, rename it like your locale id, without ".utf8". In my case:
|
||||
|
||||
$ lua
|
||||
Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio
|
||||
> print(os.getenv("LANG"))
|
||||
it_IT.utf8
|
||||
>
|
||||
|
||||
hence my file (Italian localization) has been named "it_IT".
|
||||
|
||||
**NOTE:** If you create a localization, feel free to send me! I will add it.
|
||||
|
||||
Screenshot
|
||||
-----
|
||||
![Screenshot][1]
|
||||
|
||||
[1]: http://i.imgur.com/6JtjdBF.jpg
|
||||
|
||||
License
|
||||
-----
|
||||
<a href="http://www.wtfpl.net"><img src="http://www.wtfpl.net/wp-content/uploads/2012/12/logo-220x1601.png"/></a>
|
BIN
yawn/icons/00.png
Executable file
After Width: | Height: | Size: 9.6 KiB |
BIN
yawn/icons/01.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/02.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/03.png
Executable file
After Width: | Height: | Size: 8.8 KiB |
BIN
yawn/icons/04.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/05.png
Executable file
After Width: | Height: | Size: 13 KiB |
BIN
yawn/icons/06.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
yawn/icons/07.png
Executable file
After Width: | Height: | Size: 7.9 KiB |
BIN
yawn/icons/08.png
Executable file
After Width: | Height: | Size: 9.5 KiB |
BIN
yawn/icons/09.png
Executable file
After Width: | Height: | Size: 8.6 KiB |
BIN
yawn/icons/10.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
yawn/icons/11.png
Executable file
After Width: | Height: | Size: 9.7 KiB |
BIN
yawn/icons/12.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/13.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
yawn/icons/14.png
Executable file
After Width: | Height: | Size: 7.8 KiB |
BIN
yawn/icons/15.png
Executable file
After Width: | Height: | Size: 8 KiB |
BIN
yawn/icons/16.png
Executable file
After Width: | Height: | Size: 7.2 KiB |
BIN
yawn/icons/17.png
Executable file
After Width: | Height: | Size: 8.5 KiB |
BIN
yawn/icons/18.png
Executable file
After Width: | Height: | Size: 7.3 KiB |
BIN
yawn/icons/19.png
Executable file
After Width: | Height: | Size: 6.9 KiB |
BIN
yawn/icons/20.png
Executable file
After Width: | Height: | Size: 7.8 KiB |
BIN
yawn/icons/21.png
Executable file
After Width: | Height: | Size: 6.4 KiB |
BIN
yawn/icons/22.png
Executable file
After Width: | Height: | Size: 7.4 KiB |
BIN
yawn/icons/23.png
Executable file
After Width: | Height: | Size: 5.1 KiB |
BIN
yawn/icons/24.png
Executable file
After Width: | Height: | Size: 6 KiB |
BIN
yawn/icons/25.png
Executable file
After Width: | Height: | Size: 6.4 KiB |
BIN
yawn/icons/26.png
Executable file
After Width: | Height: | Size: 7.3 KiB |
BIN
yawn/icons/27.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/28.png
Executable file
After Width: | Height: | Size: 9.6 KiB |
BIN
yawn/icons/29.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
yawn/icons/30.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/31.png
Executable file
After Width: | Height: | Size: 9.1 KiB |
BIN
yawn/icons/32.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
yawn/icons/33.png
Executable file
After Width: | Height: | Size: 10 KiB |
BIN
yawn/icons/na.png
Executable file
After Width: | Height: | Size: 11 KiB |
1
yawn/icons/source
Normal file
|
@ -0,0 +1 @@
|
|||
http://merlinthered.deviantart.com/art/plain-weather-icons-157162192
|
190
yawn/init.lua
Normal file
|
@ -0,0 +1,190 @@
|
|||
-- yawn, a weather notification module for Awesome WM 3.5+
|
||||
|
||||
local os = require("os")
|
||||
local wibox = require("wibox")
|
||||
local beautiful = require("beautiful")
|
||||
local naughty = require("naughty")
|
||||
local io = require("io")
|
||||
local debug = require("debug")
|
||||
|
||||
local string = string
|
||||
local timer = timer
|
||||
local print = print
|
||||
local tonumber = tonumber
|
||||
|
||||
module('yawn')
|
||||
|
||||
local project_path = debug.getinfo(1, 'S').source:match[[^@(.*/).*$]]
|
||||
local localizations_path = project_path .. '/localizations/'
|
||||
local icon_path = project_path .. 'icons/'
|
||||
local api_url = 'http://weather.yahooapis.com/forecastrss'
|
||||
local chosen_units = '?u=c&w=' -- default is Celsius
|
||||
local weather_data = nil
|
||||
local notification = nil
|
||||
local city_id = nil
|
||||
sky_na = icon_path .. "na.png"
|
||||
local sky = nil
|
||||
local chosen_color = nil
|
||||
local language = string.gsub(os.getenv("LANG"), ".utf8", "")
|
||||
|
||||
icon = wibox.widget.imagebox()
|
||||
widget = wibox.widget.textbox()
|
||||
|
||||
function execute(url, callback)
|
||||
|
||||
-- Reads from url, then runs the callback function on it
|
||||
|
||||
local f = io.popen("curl --connect-timeout 1 -fsm 3 '" .. url .. "'" )
|
||||
local ws = f:read("*all")
|
||||
f:close()
|
||||
|
||||
local execute_timer = timer({ timeout = 7 })
|
||||
execute_timer:connect_signal("timeout", function()
|
||||
execute_timer:stop()
|
||||
callback(ws)
|
||||
end)
|
||||
execute_timer:start()
|
||||
end
|
||||
|
||||
function fetch_weather()
|
||||
execute(api_url..chosen_units..city_id, function(text)
|
||||
|
||||
-- In case of no connection or invalid city ID, widgets won't display
|
||||
if text == "" or text:match("City not found")
|
||||
then
|
||||
sky = sky_na
|
||||
if text == "" then
|
||||
weather_data = "Service not available at the moment."
|
||||
else
|
||||
weather_data = "<b>City not found!</b>\n" ..
|
||||
"Are you sure " .. city_id .. " is your Yahoo city ID?"
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Processing raw data
|
||||
weather_data = text:gsub("<.->", "")
|
||||
weather_data = weather_data:match("Current Conditions:.-Full")
|
||||
weather_data = weather_data:gsub("Current Conditions:.-\n", "Now: ")
|
||||
weather_data = weather_data:gsub("Forecast:.-\n", "")
|
||||
weather_data = weather_data:gsub("\nFull", "")
|
||||
weather_data = weather_data:gsub("[\n]$", "")
|
||||
weather_data = weather_data:gsub(" [-] " , ": ")
|
||||
weather_data = weather_data:gsub("[.]", ",")
|
||||
weather_data = weather_data:gsub("High: ", "")
|
||||
weather_data = weather_data:gsub(" Low: ", " - ")
|
||||
|
||||
-- Getting info for text widget
|
||||
local now = weather_data:sub(weather_data:find("Now:")+5, weather_data:find("\n")-1)
|
||||
local forecast = now:sub(1, now:find(",")-1)
|
||||
local units = now:sub(now:find(",")+2, -2)
|
||||
|
||||
-- Day/Night icon change
|
||||
hour = tonumber(os.date("%H")) if hour >= 6 and hour <= 18
|
||||
then -- Day
|
||||
if forecast == "Clear" or forecast == "Fair" then sky = icon_path .. "24.png"
|
||||
elseif forecast == "Partly Cloudy" then sky = icon_path .. "26.png"
|
||||
elseif forecast == "Mostly Cloudy" then sky = icon_path .. "20.png"
|
||||
end
|
||||
else -- Night
|
||||
if forecast == "Clear" or forecast == "Fair" then sky = icon_path .. "23.png"
|
||||
elseif forecast == "Partly Cloudy" then sky = icon_path .. "25.png"
|
||||
elseif forecast == "Mostly Cloudy" then sky = icon_path .. "19.png"
|
||||
end
|
||||
end
|
||||
|
||||
if sky == nil then
|
||||
if forecast == "Cloudy" then sky = icon_path .. "18.png"
|
||||
elseif forecast == "Sunny" then sky = icon_path .. "10.png"
|
||||
elseif forecast == "Rain/Thunder" then sky = icon_path .. "00.png"
|
||||
elseif forecast == "Light Snow Showers" then sky = icon_path .. "09.png"
|
||||
elseif forecast == "Snow Flurries" or
|
||||
forecast == "Blowing Snow" then sky = icon_path .. "12.png"
|
||||
elseif forecast:find("Snow Showers") ~= nil or
|
||||
forecast:find("Snow") ~= nil or
|
||||
forecast:find("Sleet") ~= nil then sky = icon_path .. "11.png"
|
||||
elseif forecast == "Mixed Rain And Snow" then sky = icon_path .. "02.png"
|
||||
elseif forecast == "Mixed Rain And Sleet" then sky = icon_path .. "04.png"
|
||||
elseif forecast == "Mixed Rain And Hail" then sky = icon_path .. "03.png"
|
||||
elseif forecast == "Freezing Drizzle" then sky = icon_path .. "05.png"
|
||||
elseif forecast == "Freezing Rain" then sky = icon_path .. "06png"
|
||||
elseif forecast:find("Wind") ~= nil then sky = icon_path .. "17.png"
|
||||
elseif forecast == "Heavy Snow" then sky = icon_path .. "13.png"
|
||||
elseif forecast:find("Rain") ~= nil or
|
||||
forecast:find("Drizzle") ~= nil then sky = icon_path .. "07.png"
|
||||
elseif forecast:find("Showers") ~= nil or
|
||||
forecast:find("Thunderstorm") ~= nil or
|
||||
forecast:find("Thunder") ~= nil then sky = icon_path .. "08.png"
|
||||
elseif forecast == "Hail" then sky = icon_path .. "14.png"
|
||||
elseif forecast == "Foggy" or forecast == "Haze" then sky = icon_path .. "16.png"
|
||||
else sky = sky_na
|
||||
end
|
||||
end
|
||||
|
||||
-- Setting widgets
|
||||
icon:set_image(sky)
|
||||
widget:set_markup(" <span font='Tamsyn 10' color='" .. chosen_color .. "'>" .. units .. "</span>")
|
||||
|
||||
-- Localization
|
||||
if language:find("en_") == nil
|
||||
then
|
||||
for line in io.lines(localizations_path .. language)
|
||||
do
|
||||
word = string.sub(line, 1, line:find("|")-1)
|
||||
translation = string.sub(line, line:find("|")+1)
|
||||
weather_data = string.gsub(weather_data, word, translation)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function remove_weather()
|
||||
if notification ~= nil then
|
||||
naughty.destroy(notification)
|
||||
notification = nil
|
||||
end
|
||||
end
|
||||
|
||||
function show_weather(t_out)
|
||||
fetch_weather()
|
||||
remove_weather()
|
||||
notification = naughty.notify({
|
||||
text = weather_data,
|
||||
icon = sky,
|
||||
timeout = t_out,
|
||||
hover_timeout = 0.5,
|
||||
--fg = beautiful.fg_normal,
|
||||
fg = "#D4D4D4",
|
||||
bg = beautiful.bg_normal
|
||||
})
|
||||
end
|
||||
|
||||
function register(id, color, u)
|
||||
if u == "f" then chosen_units = '?u=f&w=' end
|
||||
chosen_color = color or "#d7d7d7"
|
||||
city_id = id
|
||||
fetch_weather()
|
||||
update_timer = timer({ timeout = 600 })
|
||||
update_timer:connect_signal("timeout", function()
|
||||
fetch_weather()
|
||||
end)
|
||||
update_timer:start()
|
||||
fetch_weather()
|
||||
|
||||
icon:connect_signal("mouse::enter", function()
|
||||
show_weather(0)
|
||||
end)
|
||||
icon:connect_signal("mouse::leave", function()
|
||||
remove_weather()
|
||||
end)
|
||||
end
|
||||
|
||||
function attach(widget, id, u)
|
||||
register(id, nil, u)
|
||||
widget:connect_signal("mouse::enter", function()
|
||||
show_weather(0)
|
||||
end)
|
||||
widget:connect_signal("mouse::leave", function()
|
||||
remove_weather()
|
||||
end)
|
||||
end
|
56
yawn/localizations/it_IT
Normal file
|
@ -0,0 +1,56 @@
|
|||
Now:|Ora:
|
||||
Sun:|Dom:
|
||||
Mon:|Lun:
|
||||
Tue:|Mar:
|
||||
Wed:|Mer:
|
||||
Thu:|Gio:
|
||||
Fri:|Ven:
|
||||
Sat:|Sab:
|
||||
Mostly Sunny|Abbastanza Soleggiato
|
||||
Sunny|Soleggiato
|
||||
Sun|Soleggiato
|
||||
Rain/Thunder|Temporali
|
||||
Isolated Thunderstorms|Temporali Isolati
|
||||
Scattered Thunderstorms|Temporali Sparsi
|
||||
Thundershowers|Rovesci Temporaleschi
|
||||
Thunderstorms|Temporali
|
||||
Thunder|Temporale
|
||||
AM|In Mattinata
|
||||
PM|Nel Pomeriggio
|
||||
Early|In Mattinata
|
||||
Late|In Serata
|
||||
Few|Sporadiche
|
||||
Severe|Forti
|
||||
Clear|Sereno
|
||||
Fair|Sereno
|
||||
Partly|Parzialmente
|
||||
Mostly|Molto
|
||||
Cloudy|Nuvoloso
|
||||
Clouds|Nuvoloso
|
||||
Scattered Showers|Temporali Sparsi
|
||||
Light Snow Showers|Nevicate Leggere
|
||||
Snow Showers|Nevicate
|
||||
Heavy Snow|Forti Nevicate
|
||||
Scattered Snow Showers|Nevicate Sparse
|
||||
Mixed Rain And Snow|Pioggia E Neve
|
||||
Mixed Rain And Sleet|Pioggia E Nevischio
|
||||
Mixed Snow And Sleet|Neve E Nevischio
|
||||
Mixed Rain And Hail|Pioggia E Grandine
|
||||
Snow Flurries|Folate Di Neve
|
||||
Blowing Snow|Neve Battente
|
||||
Blowing Rain|Pioggia Battente
|
||||
Heavy Rain|Forti Piogge
|
||||
Freezing Rain|Pioggia Congelantesi
|
||||
Showers|Piogge
|
||||
Light Rain|Pioggia Leggera
|
||||
Rain|Piovoso
|
||||
Windy|Ventoso
|
||||
Wind|Ventoso
|
||||
Snow|Neve
|
||||
Sleet|Nevischio
|
||||
Drizzle|Pioggerella
|
||||
Freezing Drizzle|Pioggerella Congelantesi
|
||||
Hail|Grandine
|
||||
Foggy|Nebbia
|
||||
Haze|Nebbia
|
||||
Light|Leggere
|
56
yawn/localizations/localization_stub
Normal file
|
@ -0,0 +1,56 @@
|
|||
Now:|
|
||||
Sun:|
|
||||
Mon:|
|
||||
Tue:|
|
||||
Wed:|
|
||||
Thu:|
|
||||
Fri:|
|
||||
Sat:|
|
||||
Mostly Sunny|
|
||||
Sunny|
|
||||
Sun|
|
||||
Rain/Thunder|
|
||||
Isolated Thunderstorms|
|
||||
Scattered Thunderstorms|
|
||||
Thundershowers|
|
||||
Thunderstorms|
|
||||
Thunder|
|
||||
AM|
|
||||
PM|
|
||||
Early|
|
||||
Late|
|
||||
Few|
|
||||
Severe|
|
||||
Clear|
|
||||
Fair|
|
||||
Partly|
|
||||
Mostly|
|
||||
Cloudy|
|
||||
Clouds|
|
||||
Scattered Showers|
|
||||
Light Snow Showers|
|
||||
Snow Showers|
|
||||
Heavy Snow|
|
||||
Scattered Snow Showers|
|
||||
Mixed Rain And Snow|
|
||||
Mixed Rain And Sleet|
|
||||
Mixed Snow And Sleet|
|
||||
Mixed Rain And Hail|
|
||||
Snow Flurries|
|
||||
Blowing Snow|
|
||||
Blowing Rain|
|
||||
Heavy Rain|
|
||||
Freezing Rain|
|
||||
Showers|
|
||||
Light Rain|
|
||||
Rain|
|
||||
Windy|
|
||||
Wind|
|
||||
Snow|
|
||||
Sleet|
|
||||
Drizzle|
|
||||
Freezing Drizzle|
|
||||
Hail|
|
||||
Foggy|
|
||||
Haze|
|
||||
Light|
|