@@ -66,6 +66,7 @@ local weather_popup = awful.popup {
66
66
67
67
--- Maps WeatherAPI condition code to file name w/o extension
68
68
--- See https://www.weatherapi.com/docs/#weather-icons
69
+ --- Day/Night is determined at time of mapping the weather to an icon
69
70
local icon_map = {
70
71
[1000 ] = " clear-sky" ,
71
72
[1003 ] = " few-clouds" ,
@@ -293,8 +294,13 @@ local function worker(user_args)
293
294
forced_width = 300 ,
294
295
layout = wibox .layout .flex .horizontal ,
295
296
update = function (self , weather )
297
+ local day_night_extension = " "
298
+ if weather .is_day then
299
+ day_night_extension = " -night"
300
+ end
301
+
296
302
self :get_children_by_id (' icon' )[1 ]:set_image (
297
- ICONS_DIR .. icon_map [weather .condition .code ] .. icons_extension )
303
+ ICONS_DIR .. icon_map [weather .condition .code ] .. day_night_extension .. icons_extension )
298
304
self :get_children_by_id (' temp' )[1 ]:set_text (gen_temperature_str (weather .temp_c , ' %.0f' , false , units ))
299
305
self :get_children_by_id (' feels_like_temp' )[1 ]:set_text (
300
306
LCLE .feels_like .. gen_temperature_str (weather .feelslike_c , ' %.0f' , false , units ))
@@ -315,6 +321,11 @@ local function worker(user_args)
315
321
for i , day in ipairs (forecast ) do
316
322
-- Free plan allows forecast for up to three days, each with hours
317
323
if i > 3 then break end
324
+ local day_night_extension = " "
325
+ if day .is_day then
326
+ day_night_extension = " -night"
327
+ end
328
+
318
329
local day_forecast = wibox .widget {
319
330
{
320
331
text = os.date (' %a' , tonumber (day .date_epoch )),
@@ -325,7 +336,10 @@ local function worker(user_args)
325
336
{
326
337
{
327
338
{
328
- image = ICONS_DIR .. icon_map [day .day .condition .code ] .. icons_extension ,
339
+ image = ICONS_DIR
340
+ .. icon_map [day .day .condition .code ]
341
+ .. day_night_extension
342
+ .. icons_extension ,
329
343
resize = true ,
330
344
forced_width = 48 ,
331
345
forced_height = 48 ,
@@ -575,7 +589,13 @@ local function worker(user_args)
575
589
widget :is_ok (true )
576
590
577
591
local result = json .decode (stdout )
578
- widget :set_image (ICONS_DIR .. icon_map [result .current .condition .code ] .. icons_extension )
592
+
593
+ local day_night_extension = " "
594
+ if result .current .is_day then
595
+ day_night_extension = " -night"
596
+ end
597
+
598
+ widget :set_image (ICONS_DIR .. icon_map [result .current .condition .code ] .. day_night_extension .. icons_extension )
579
599
-- TODO: if units isn't "metric", read temp_f instead
580
600
widget :set_text (gen_temperature_str (result .current .temp_c , ' %.0f' , both_units_widget , units ))
581
601
0 commit comments