X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/ddbf283f0ebbc6772d485fe76c5dccf338d3b837..2c1eb09080947d4f587e001497f12c6084babffa:/widgets/weather.lua diff --git a/widgets/weather.lua b/widgets/weather.lua index 9f83dc8..9e1b80e 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -25,7 +25,7 @@ local setmetatable = setmetatable -- lain.widgets.weather local function worker(args) - local weather = helpers.make_widget_textbox() + local weather = { widget = wibox.widget.textbox() } local args = args or {} local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default local timeout = args.timeout or 900 -- 15 min @@ -68,6 +68,7 @@ local function worker(args) end if not weather.notification_text then + weather.update() weather.forecast_update() end @@ -129,7 +130,13 @@ local function worker(args) local icon = weather_now["weather"][1]["icon"] local loc_m = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 } local offset = utc_offset() - local utc_m = loc_m + offset + local utc_m = loc_m - offset + + if offset > 0 and (now - utc_m)>=86400 then + utc_m = utc_m + 86400 + elseif offset < 0 and (utc_m - now)>=86400 then + utc_m = utc_m - 86400 + end -- if we are 1 day after the GMT, return 1 day back, and viceversa if offset > 0 and loc_m >= utc_m then