X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/8d3868d7ce528cfc075e246c8935bae2724e0868..0ef78642276735127d2206be184c1e071ad6b0ed:/widget/weather.lua diff --git a/widget/weather.lua b/widget/weather.lua index 1b2e80f..82c8ebf 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -6,25 +6,24 @@ --]] -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 @@ -54,6 +53,7 @@ local function worker(args) 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) @@ -163,7 +163,7 @@ local function worker(args) 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) @@ -171,4 +171,4 @@ local function worker(args) return weather end -return setmetatable({}, { __call = function(_, ...) return worker(...) end }) +return factory