Few small improvements for weather widget
This commit is contained in:
parent
e1b7bab9c9
commit
10ffee904f
|
@ -57,7 +57,7 @@ function to_celcius(kelvin)
|
||||||
return math.floor(tonumber(kelvin) - 273.15)
|
return math.floor(tonumber(kelvin) - 273.15)
|
||||||
end
|
end
|
||||||
|
|
||||||
local weather_timer = timer({ timeout = 600 })
|
local weather_timer = timer({ timeout = 60 })
|
||||||
local resp
|
local resp
|
||||||
|
|
||||||
weather_timer:connect_signal("timeout", function ()
|
weather_timer:connect_signal("timeout", function ()
|
||||||
|
@ -71,18 +71,23 @@ end)
|
||||||
weather_timer:start()
|
weather_timer:start()
|
||||||
weather_timer:emit_signal("timeout")
|
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()
|
weather_widget:connect_signal("mouse::enter", function()
|
||||||
notification = naughty.notify{
|
notification = naughty.notify{
|
||||||
icon = path_to_icons .. icon_map[resp.weather[1].icon],
|
icon = path_to_icons .. icon_map[resp.weather[1].icon],
|
||||||
icon_size=20,
|
icon_size=20,
|
||||||
text =
|
text =
|
||||||
'<big>' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')</big><br>' ..
|
'<big>' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')</big><br>' ..
|
||||||
'<b>Humidity:</b> ' .. resp.main.humidity .. '%<br>' ..
|
'<b>Humidity:</b> ' .. resp.main.humidity .. '%<br>' ..
|
||||||
'<b>Temperature: </b>' .. to_celcius(resp.main.temp) .. '<br>' ..
|
'<b>Temperature: </b>' .. to_celcius(resp.main.temp) .. '<br>' ..
|
||||||
'<b>Pressure: </b>' .. resp.main.pressure .. 'hPa<br>' ..
|
'<b>Pressure: </b>' .. resp.main.pressure .. 'hPa<br>' ..
|
||||||
'<b>Clouds: </b>' .. resp.clouds.all .. '%<br>' ..
|
'<b>Clouds: </b>' .. resp.clouds.all .. '%<br>' ..
|
||||||
'<b>Wind: </b>' .. resp.wind.speed .. 'm/s',
|
'<b>Wind: </b>' .. resp.wind.speed .. 'm/s',
|
||||||
timeout = 5, hover_timeout = 10,
|
timeout = 5, hover_timeout = 10,
|
||||||
width = 200,
|
width = 200
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
weather_widget:connect_signal("mouse::leave", function()
|
||||||
|
naughty.destroy(notification)
|
||||||
|
end)
|
Loading…
Reference in New Issue