]> git.madduck.net Git - etc/awesome.git/blobdiff - widget/weather.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

widget.contrib.gpmdp: moved to awesome-www recipes; closes #354 #343 #342
[etc/awesome.git] / widget / weather.lua
index 1b2e80f9f6051aa4e3a524666627de3359d68bfd..82c8ebf4b2edbe70b75b404a9d0ee6400fdef826 100644 (file)
@@ -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