X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/6b0e66f721edd5efbd70d3507584625b18ecb3d7..6ff56e857e13e266eb02d96167132159aa3677f5:/widgets/weather.lua diff --git a/widgets/weather.lua b/widgets/weather.lua index d2ed300..015f43a 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -13,6 +13,7 @@ local async = require("lain.asyncshell") local json = require("lain.util").dkjson local lain_icons = require("lain.helpers").icons_dir +local focused = require("awful.screen").focused local naughty = require("naughty") local wibox = require("wibox") @@ -60,7 +61,7 @@ local function worker(args) return string.format("%s: %s, %d - %d ", day, desc, tmin, tmax) end local weather_na_markup = args.weather_na_markup or " N/A " - local followmouse = args.followmouse or false + local followtag = args.followtag or false local settings = args.settings or function() end weather.widget = wibox.widget.textbox(weather_na_markup) @@ -70,8 +71,8 @@ local function worker(args) function weather.show(t_out) weather.hide() - if followmouse then - notification_preset.screen = mouse.screen + if followtag then + notification_preset.screen = focused() end if not weather.notification_text then @@ -108,7 +109,7 @@ local function worker(args) local pos, err weather_now, pos, err = json.decode(f, 1, nil) - if not err and weather_now and tonumber(weather_now["cod"]) == 200 then + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then weather.notification_text = '' for i = 1, weather_now["cnt"] do weather.notification_text = weather.notification_text .. @@ -128,7 +129,7 @@ local function worker(args) local pos, err, icon weather_now, pos, err = json.decode(f, 1, nil) - if not err and weather_now and tonumber(weather_now["cod"]) == 200 then + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then -- weather icon based on localtime local now = os.time() local sunrise = tonumber(weather_now["sys"]["sunrise"])