diff options
Diffstat (limited to '.config/awesome/lain/widgets/yawn')
41 files changed, 339 insertions, 0 deletions
diff --git a/.config/awesome/lain/widgets/yawn/icons/BlowingSnow.png b/.config/awesome/lain/widgets/yawn/icons/BlowingSnow.png Binary files differnew file mode 100755 index 0000000..6223f8f --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/BlowingSnow.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Cloudy.png b/.config/awesome/lain/widgets/yawn/icons/Cloudy.png Binary files differnew file mode 100755 index 0000000..bac1e7e --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Cloudy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/DayClear.png b/.config/awesome/lain/widgets/yawn/icons/DayClear.png Binary files differnew file mode 100755 index 0000000..d9e2745 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/DayClear.png diff --git a/.config/awesome/lain/widgets/yawn/icons/DayFair.png b/.config/awesome/lain/widgets/yawn/icons/DayFair.png new file mode 120000 index 0000000..8ee94d1 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/DayFair.png @@ -0,0 +1 @@ +DayClear.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/DayMostlyCloudy.png b/.config/awesome/lain/widgets/yawn/icons/DayMostlyCloudy.png Binary files differnew file mode 100755 index 0000000..22b929c --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/DayMostlyCloudy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/DayPartlyCloudy.png b/.config/awesome/lain/widgets/yawn/icons/DayPartlyCloudy.png Binary files differnew file mode 100755 index 0000000..8fd0a5b --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/DayPartlyCloudy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Drizzle.png b/.config/awesome/lain/widgets/yawn/icons/Drizzle.png new file mode 120000 index 0000000..df34463 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Drizzle.png @@ -0,0 +1 @@ +Rain.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/Fog.png b/.config/awesome/lain/widgets/yawn/icons/Fog.png new file mode 120000 index 0000000..b615645 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Fog.png @@ -0,0 +1 @@ +Foggy.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/Foggy.png b/.config/awesome/lain/widgets/yawn/icons/Foggy.png Binary files differnew file mode 100755 index 0000000..009039f --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Foggy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/FreezingDrizzle.png b/.config/awesome/lain/widgets/yawn/icons/FreezingDrizzle.png Binary files differnew file mode 100755 index 0000000..6a66140 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/FreezingDrizzle.png diff --git a/.config/awesome/lain/widgets/yawn/icons/FreezingRain.png b/.config/awesome/lain/widgets/yawn/icons/FreezingRain.png Binary files differnew file mode 100755 index 0000000..c924fac --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/FreezingRain.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Hail.png b/.config/awesome/lain/widgets/yawn/icons/Hail.png Binary files differnew file mode 100755 index 0000000..009039f --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Hail.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Haze.png b/.config/awesome/lain/widgets/yawn/icons/Haze.png new file mode 120000 index 0000000..0874a83 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Haze.png @@ -0,0 +1 @@ +Hail.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/HeavyRain.png b/.config/awesome/lain/widgets/yawn/icons/HeavyRain.png new file mode 120000 index 0000000..ace2a94 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/HeavyRain.png @@ -0,0 +1 @@ +Showers.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/HeavySnow.png b/.config/awesome/lain/widgets/yawn/icons/HeavySnow.png Binary files differnew file mode 100755 index 0000000..ddcb8f3 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/HeavySnow.png diff --git a/.config/awesome/lain/widgets/yawn/icons/LightRain.png b/.config/awesome/lain/widgets/yawn/icons/LightRain.png new file mode 120000 index 0000000..df34463 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/LightRain.png @@ -0,0 +1 @@ +Rain.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/LightSnow.png b/.config/awesome/lain/widgets/yawn/icons/LightSnow.png new file mode 120000 index 0000000..aa8b28e --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/LightSnow.png @@ -0,0 +1 @@ +LightSnowShowers.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/LightSnowShowers.png b/.config/awesome/lain/widgets/yawn/icons/LightSnowShowers.png Binary files differnew file mode 100755 index 0000000..d797ee9 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/LightSnowShowers.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Mist.png b/.config/awesome/lain/widgets/yawn/icons/Mist.png new file mode 120000 index 0000000..b615645 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Mist.png @@ -0,0 +1 @@ +Foggy.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/MixedRainAndHail.png b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndHail.png Binary files differnew file mode 100755 index 0000000..758b01e --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndHail.png diff --git a/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSleet.png b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSleet.png Binary files differnew file mode 100755 index 0000000..7f0d252 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSleet.png diff --git a/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSnow.png b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSnow.png Binary files differnew file mode 100755 index 0000000..0a07b7b --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/MixedRainAndSnow.png diff --git a/.config/awesome/lain/widgets/yawn/icons/NightClear.png b/.config/awesome/lain/widgets/yawn/icons/NightClear.png Binary files differnew file mode 100755 index 0000000..84ea140 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/NightClear.png diff --git a/.config/awesome/lain/widgets/yawn/icons/NightFair.png b/.config/awesome/lain/widgets/yawn/icons/NightFair.png new file mode 120000 index 0000000..23df45a --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/NightFair.png @@ -0,0 +1 @@ +NightClear.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/NightMostlyCloudy.png b/.config/awesome/lain/widgets/yawn/icons/NightMostlyCloudy.png Binary files differnew file mode 100755 index 0000000..d8b3673 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/NightMostlyCloudy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/NightPartlyCloudy.png b/.config/awesome/lain/widgets/yawn/icons/NightPartlyCloudy.png Binary files differnew file mode 100755 index 0000000..9e4404d --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/NightPartlyCloudy.png diff --git a/.config/awesome/lain/widgets/yawn/icons/README.md b/.config/awesome/lain/widgets/yawn/icons/README.md new file mode 100644 index 0000000..e4dc111 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/README.md @@ -0,0 +1,6 @@ +Yawn icons +========== + +These are [Plain Weather Icons](http://merlinthered.deviantart.com/art/plain-weather-icons-157162192), created by [MerlinTheRed](http://merlinthered.deviantart.com/). + +<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/"><img src="http://i.creativecommons.org/l/by-nc-sa/2.5/80x15.png" align="right"></a> diff --git a/.config/awesome/lain/widgets/yawn/icons/Rain.png b/.config/awesome/lain/widgets/yawn/icons/Rain.png Binary files differnew file mode 100755 index 0000000..d00552a --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Rain.png diff --git a/.config/awesome/lain/widgets/yawn/icons/RainThunder.png b/.config/awesome/lain/widgets/yawn/icons/RainThunder.png Binary files differnew file mode 100755 index 0000000..d30e120 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/RainThunder.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Showers.png b/.config/awesome/lain/widgets/yawn/icons/Showers.png Binary files differnew file mode 100755 index 0000000..3cc6665 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Showers.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Sleet.png b/.config/awesome/lain/widgets/yawn/icons/Sleet.png new file mode 120000 index 0000000..f8f9693 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Sleet.png @@ -0,0 +1 @@ +SnowShowers.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/Snow.png b/.config/awesome/lain/widgets/yawn/icons/Snow.png new file mode 120000 index 0000000..f8f9693 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Snow.png @@ -0,0 +1 @@ +SnowShowers.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/SnowFlurries.png b/.config/awesome/lain/widgets/yawn/icons/SnowFlurries.png new file mode 120000 index 0000000..2e090cd --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/SnowFlurries.png @@ -0,0 +1 @@ +BlowingSnow.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/SnowShowers.png b/.config/awesome/lain/widgets/yawn/icons/SnowShowers.png Binary files differnew file mode 100755 index 0000000..30534a2 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/SnowShowers.png diff --git a/.config/awesome/lain/widgets/yawn/icons/Sunny.png b/.config/awesome/lain/widgets/yawn/icons/Sunny.png Binary files differnew file mode 100755 index 0000000..cf08c5c --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Sunny.png diff --git a/.config/awesome/lain/widgets/yawn/icons/ThunderintheVicinity.png b/.config/awesome/lain/widgets/yawn/icons/ThunderintheVicinity.png new file mode 120000 index 0000000..1fb3b9c --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/ThunderintheVicinity.png @@ -0,0 +1 @@ +Cloudy.png
\ No newline at end of file diff --git a/.config/awesome/lain/widgets/yawn/icons/Wind.png b/.config/awesome/lain/widgets/yawn/icons/Wind.png Binary files differnew file mode 100755 index 0000000..5dc1356 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/Wind.png diff --git a/.config/awesome/lain/widgets/yawn/icons/na.png b/.config/awesome/lain/widgets/yawn/icons/na.png Binary files differnew file mode 100755 index 0000000..62a5350 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/icons/na.png diff --git a/.config/awesome/lain/widgets/yawn/init.lua b/.config/awesome/lain/widgets/yawn/init.lua new file mode 100644 index 0000000..3f08cd5 --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/init.lua @@ -0,0 +1,200 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luke Bonham + +--]] + +local newtimer = require("lain.helpers").newtimer + +local naughty = require("naughty") +local wibox = require("wibox") + +local debug = { getinfo = debug.getinfo } +local io = io +local os = { date = os.date, + getenv = os.getenv } +local string = { find = string.find, + match = string.match, + gsub = string.gsub, + sub = string.sub } +local tonumber = tonumber + +local setmetatable = setmetatable + +-- YAhoo! Weather Notification +-- lain.widgets.yawn +local yawn = +{ + icon = wibox.widget.imagebox(), + widget = wibox.widget.textbox('') +} + +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 units_set = '?u=c&w=' -- Default is Celsius +local language = string.match(os.getenv("LANG"), "(%S*$*)[.]") +local weather_data = nil +local notification = nil +local city_id = nil +local sky = nil +local settings = function() end + +yawn_notification_preset = {} + +local function fetch_weather() + local url = api_url .. units_set .. city_id + local f = io.popen("curl --connect-timeout 1 -fsm 3 '" .. url .. "'" ) + local text = f:read("*all") + f:close() + + -- In case of no connection or invalid city ID + -- widgets won't display + if text == "" or text:match("City not found") + then + yawn.icon:set_image(icon_path .. "na.png") + if text == "" then + weather_data = "Service not available at the moment." + yawn.widget:set_text(" N/A ") + else + weather_data = "City not found!\n" .. + "Are you sure " .. city_id .. + " is your Yahoo city ID?" + yawn.widget:set_text(" ? ") + end + return + end + + -- Processing raw data + weather_data = text:gsub("<.->", "") + weather_data = weather_data:match("Current Conditions:.-Full") or "" + + -- may still happens in case of bad connectivity + if weather_data == "" then + yawn.icon:set_image(icon_path .. "na.png") + yawn.widget:set_text(" ? ") + return + end + + 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) + forecast = now:sub(1, now:find(",")-1) + units = now:sub(now:find(",")+2, -2) + + -- Day/Night icon change + local hour = tonumber(os.date("%H")) + sky = icon_path + + if forecast == "Clear" or + forecast == "Fair" or + forecast == "Partly Cloudy" or + forecast == "Mostly Cloudy" + then + if hour >= 6 and hour <= 18 + then + sky = sky .. "Day" + else + sky = sky .. "Night" + end + end + + sky = sky .. forecast:gsub(" ", ""):gsub("/", "") .. ".png" + + -- In case there's no defined icon for current forecast + if io.open(sky) == nil then + sky = icon_path .. "na.png" + end + + -- Localization + local f = io.open(localizations_path .. language, "r") + if language:find("en_") == nil and f ~= nil + then + f:close() + 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 + + -- Finally setting infos + yawn.icon:set_image(sky) + widget = yawn.widget + + forecast = weather_data:match(": %S.-,"):gsub(": ", ""):gsub(",", "") + units = units:gsub(" ", "") + + settings() +end + +function yawn.hide() + if notification ~= nil then + naughty.destroy(notification) + notification = nil + end +end + +function yawn.show(t_out) + if yawn.widget._layout.text:match("?") + then + fetch_weather(settings) + end + + yawn.hide() + + notification = naughty.notify({ + preset = yawn_notification_preset, + text = weather_data, + icon = sky, + timeout = t_out + }) +end + +function yawn.register(id, args) + local args = args or {} + local timeout = args.timeout or 600 + settings = args.settings or function() end + + if args.u == "f" then units_set = '?u=f&w=' end + + city_id = id + + newtimer("yawn", timeout, fetch_weather) + + yawn.icon:connect_signal("mouse::enter", function() + yawn.show(0) + end) + yawn.icon:connect_signal("mouse::leave", function() + yawn.hide() + end) + + return yawn +end + +function yawn.attach(widget, id, args) + yawn.register(id, args) + + widget:connect_signal("mouse::enter", function() + yawn.show(0) + end) + + widget:connect_signal("mouse::leave", function() + yawn.hide() + end) +end + +return setmetatable(yawn, { __call = function(_, ...) return yawn.register(...) end }) diff --git a/.config/awesome/lain/widgets/yawn/localizations/it_IT b/.config/awesome/lain/widgets/yawn/localizations/it_IT new file mode 100644 index 0000000..70b0eef --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/localizations/it_IT @@ -0,0 +1,60 @@ +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 in the Vicinity|Tuoni in prossimità +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 +aeavy 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 +Heavy|Forti +Rain|Piovoso +Windy|Ventoso +Wind|Ventoso +Snow|Neve +Sleet|Nevischio +Light Drizzle|Pioggia Leggera +Drizzle|Pioggia Leggera +Freezing Drizzle|Pioggerella Congelantesi +Hail|Grandine +Fog|Nebbia +Foggy|Nebbioso +Haze|Nebbia +Light|Leggere diff --git a/.config/awesome/lain/widgets/yawn/localizations/localization_template b/.config/awesome/lain/widgets/yawn/localizations/localization_template new file mode 100644 index 0000000..453807e --- /dev/null +++ b/.config/awesome/lain/widgets/yawn/localizations/localization_template @@ -0,0 +1,60 @@ +Now:| +Sun:| +Mon:| +Tue:| +Wed:| +Thu:| +Fri:| +Sat:| +Mostly Sunny| +Sunny| +Sun| +Rain/Thunder| +Isolated Thunderstorms| +Scattered Thunderstorms| +Thundershowers| +Thunderstorms| +Thunder in the Vicinity| +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| +Heavy| +Rain| +Windy| +Wind| +Snow| +Sleet| +Freezing Drizzle| +Light Drizzle| +Drizzle| +Hail| +Fog| +Foggy| +Haze| +Light| |