small refactoring
This commit is contained in:
parent
150b950cc3
commit
472d03be0e
|
@ -21,7 +21,7 @@ local icon_widget = wibox.widget {
|
||||||
resize = false,
|
resize = false,
|
||||||
widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
},
|
},
|
||||||
layout = wibox.container.margin(brightness_icon, 0, 0, 3),
|
layout = wibox.container.margin(_ , 0, 0, 3),
|
||||||
set_image = function(self, path)
|
set_image = function(self, path)
|
||||||
self.icon.image = path
|
self.icon.image = path
|
||||||
end,
|
end,
|
||||||
|
@ -38,7 +38,7 @@ local weather_widget = wibox.widget {
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- helps to map openWeatherMap icons to Arc icons
|
--- Maps openWeatherMap icons to Arc icons
|
||||||
local icon_map = {
|
local icon_map = {
|
||||||
["01d"] = "weather-clear-symbolic.svg",
|
["01d"] = "weather-clear-symbolic.svg",
|
||||||
["02d"] = "weather-few-clouds-symbolic.svg",
|
["02d"] = "weather-few-clouds-symbolic.svg",
|
||||||
|
@ -60,12 +60,12 @@ local icon_map = {
|
||||||
["50n"] = "weather-fog-symbolic.svg"
|
["50n"] = "weather-fog-symbolic.svg"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- handy function to convert temperature from Kelvin to Celcius
|
--- handy function to convert temperature from Kelvin to Celcius
|
||||||
function to_celcius(kelvin)
|
function to_celcius(kelvin)
|
||||||
return math.floor(tonumber(kelvin) - 273.15)
|
return math.floor(tonumber(kelvin) - 273.15)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return wind direction as a string.
|
--- Return wind direction as a string.
|
||||||
function to_direction(degrees)
|
function to_direction(degrees)
|
||||||
-- Ref: https://www.campbellsci.eu/blog/convert-wind-directions
|
-- Ref: https://www.campbellsci.eu/blog/convert-wind-directions
|
||||||
if degrees == nil then
|
if degrees == nil then
|
||||||
|
@ -107,7 +107,7 @@ end)
|
||||||
weather_timer:start()
|
weather_timer:start()
|
||||||
weather_timer:emit_signal("timeout")
|
weather_timer:emit_signal("timeout")
|
||||||
|
|
||||||
-- Notification with weather information. Popups when mouse hovers over the icon
|
--- Notification with weather information. Popups when mouse hovers over the icon
|
||||||
local notification
|
local notification
|
||||||
weather_widget:connect_signal("mouse::enter", function()
|
weather_widget:connect_signal("mouse::enter", function()
|
||||||
notification = naughty.notify{
|
notification = naughty.notify{
|
||||||
|
@ -124,6 +124,7 @@ weather_widget:connect_signal("mouse::enter", function()
|
||||||
width = 200
|
width = 200
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
weather_widget:connect_signal("mouse::leave", function()
|
weather_widget:connect_signal("mouse::leave", function()
|
||||||
naughty.destroy(notification)
|
naughty.destroy(notification)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue