Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 60 additions & 6 deletions weather-api-widget/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,31 @@ local function worker(user_args)

self:get_children_by_id('icon')[1]:set_image(
ICONS_DIR .. icon_map[weather.condition.code] .. day_night_extension .. icons_extension)
self:get_children_by_id('temp')[1]:set_text(gen_temperature_str(weather.temp_c, '%.0f', false, units))
self:get_children_by_id('temp')[1]:set_text(gen_temperature_str(
(function ()
if units == "metric" then
return weather.temp_c
else
return weather.temp_f
end
end)(),
'%.0f',
false,
units
))
self:get_children_by_id('feels_like_temp')[1]:set_text(
locale.feels_like .. gen_temperature_str(weather.feelslike_c, '%.0f', false, units))
locale.feels_like .. gen_temperature_str(
(function ()
if units == "metric" then
return weather.feelslike_c
else
return weather.feelslike_f
end
end)(),
'%.0f',
false,
units
))
self:get_children_by_id('description')[1]:set_text(weather.condition.text)
self:get_children_by_id('wind')[1]:set_markup(
locale.wind .. '<b>' .. weather.wind_kph .. 'km/h (' .. weather.wind_dir .. ')</b>')
Expand Down Expand Up @@ -367,13 +389,35 @@ local function worker(user_args)
},
{
{
text = gen_temperature_str(day.day.mintemp_c, '%.0f', false, units),
text = gen_temperature_str(
(function ()
if units == "metric" then
return day.day.mintemp_c
else
return day.day.mintemp_f
end
end)(),
'%.0f',
false,
units
),
align = 'center',
font = font_name .. ' 9',
widget = wibox.widget.textbox
},
{
text = gen_temperature_str(day.day.maxtemp_c, '%.0f', false, units),
text = gen_temperature_str(
(function ()
if units == "metric" then
return day.day.maxtemp_c
else
return day.day.maxtemp_f
end
end)(),
'%.0f',
false,
units
),
align = 'center',
font = font_name .. ' 9',
widget = wibox.widget.textbox
Expand Down Expand Up @@ -604,8 +648,18 @@ local function worker(user_args)
end

widget:set_image(ICONS_DIR .. icon_map[result.current.condition.code] .. day_night_extension .. icons_extension)
-- TODO: if units isn't "metric", read temp_f instead
widget:set_text(gen_temperature_str(result.current.temp_c, '%.0f', both_units_widget, units))
widget:set_text(gen_temperature_str(
(function ()
if units == "metric" then
return result.current.temp_c
else
return result.current.temp_f
end
end)(),
'%.0f',
both_units_widget,
units
))

current_weather_widget:update(result.current)

Expand Down
Loading