--]]
-local helpers = require("lain.helpers")
-local json = require("lain.util").dkjson
-local focused = require("awful.screen").focused
-local naughty = require("naughty")
-local wibox = require("wibox")
-local math = { floor = math.floor }
-local os = { time = os.time,
- date = os.date,
- difftime = os.difftime }
-local string = { format = string.format,
- gsub = string.gsub }
-local tonumber = tonumber
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local json = require("lain.util").dkjson
+local focused = require("awful.screen").focused
+local naughty = require("naughty")
+local wibox = require("wibox")
+local math = { floor = math.floor }
+local os = { time = os.time,
+ date = os.date,
+ difftime = os.difftime }
+local string = { format = string.format,
+ gsub = string.gsub }
+local tonumber = tonumber
-- OpenWeatherMap
-- current weather and X-days forecast
-- lain.widget.weather
-local function worker(args)
+local function factory(args)
local weather = { widget = wibox.widget.textbox() }
local args = args or {}
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
end
local weather_na_markup = args.weather_na_markup or " N/A "
local followtag = args.followtag or false
+ local showpopup = args.showpopup or "on"
local settings = args.settings or function() end
weather.widget:set_markup(weather_na_markup)
end)
end
- weather.attach(weather.widget)
+ if showpopup == "on" then weather.attach(weather.widget) end
weather.timer = helpers.newtimer("weather-" .. city_id, timeout, weather.update, false, true)
weather.timer_forecast = helpers.newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true)
return weather
end
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory