From 10ffee904fbe2c586e9acae038d8445c21a8e2ca Mon Sep 17 00:00:00 2001 From: Pavel Makhov Date: Mon, 5 Jun 2017 21:14:51 -0400 Subject: Few small improvements for weather widget --- weather-widget/weather.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index d6e15d4..5ee1d39 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -57,7 +57,7 @@ function to_celcius(kelvin) return math.floor(tonumber(kelvin) - 273.15) end -local weather_timer = timer({ timeout = 600 }) +local weather_timer = timer({ timeout = 60 }) local resp weather_timer:connect_signal("timeout", function () @@ -71,18 +71,23 @@ end) weather_timer:start() weather_timer:emit_signal("timeout") +-- Notification with weather information. Popups only if mouse hovers over the icon +local notification weather_widget:connect_signal("mouse::enter", function() notification = naughty.notify{ icon = path_to_icons .. icon_map[resp.weather[1].icon], icon_size=20, - text = - '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. - 'Humidity: ' .. resp.main.humidity .. '%
' .. - 'Temperature: ' .. to_celcius(resp.main.temp) .. '
' .. - 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. - 'Clouds: ' .. resp.clouds.all .. '%
' .. - 'Wind: ' .. resp.wind.speed .. 'm/s', + text = + '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. + 'Humidity: ' .. resp.main.humidity .. '%
' .. + 'Temperature: ' .. to_celcius(resp.main.temp) .. '
' .. + 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. + 'Clouds: ' .. resp.clouds.all .. '%
' .. + 'Wind: ' .. resp.wind.speed .. 'm/s', timeout = 5, hover_timeout = 10, - width = 200, + width = 200 } end) +weather_widget:connect_signal("mouse::leave", function() + naughty.destroy(notification) +end) \ No newline at end of file -- cgit v1.2.3