]> git.madduck.net Git - etc/awesome.git/commitdiff

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:

pull #307: worker -> factory
authorcopycat-killer <dada@archlinux.info>
Wed, 8 Feb 2017 19:45:11 +0000 (20:45 +0100)
committercopycat-killer <dada@archlinux.info>
Wed, 8 Feb 2017 19:45:11 +0000 (20:45 +0100)
21 files changed:
widget/alsa.lua
widget/alsabar.lua
widget/bat.lua
widget/calendar.lua
widget/contrib/gpmdp.lua
widget/contrib/init.lua
widget/contrib/kbdlayout.lua
widget/contrib/moc.lua
widget/cpu.lua
widget/fs.lua
widget/imap.lua
widget/init.lua
widget/mem.lua
widget/mpd.lua
widget/net.lua
widget/pulseaudio.lua
widget/pulsebar.lua
widget/sysload.lua
widget/temp.lua
widget/watch.lua
widget/weather.lua

index 9406e0d64fb3e716401a2ccb66be1798a2831d87..36ccc719b3b38ac18d02b546b084bf39baf677f8 100644 (file)
@@ -7,17 +7,16 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local shell        = require("awful.util").shell
-local wibox        = require("wibox")
-local string       = { match  = string.match,
-                       format = string.format }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local shell   = require("awful.util").shell
+local wibox   = require("wibox")
+local string  = { match  = string.match,
+                  format = string.format }
 
 -- ALSA volume
 -- lain.widget.alsa
 
-local function worker(args)
+local function factory(args)
     local alsa     = { widget = wibox.widget.textbox() }
     local args     = args or {}
     local timeout  = args.timeout or 5
@@ -53,4 +52,4 @@ local function worker(args)
     return alsa
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index 4386d20b3ece454e52dd3742ccc29f620a51e3a3..ff14ed6d9541134befabcdea9efc5ecab810d7d3 100644 (file)
@@ -32,7 +32,7 @@ local alsabar = {
     _muted         = false
 }
 
-local function worker(args)
+local function factory(args)
     local args       = args or {}
     local timeout    = args.timeout or 5
     local settings   = args.settings or function() end
@@ -135,4 +135,4 @@ local function worker(args)
     return alsabar
 end
 
-return setmetatable(alsabar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(alsabar, { __call = function(_, ...) return factory(...) end })
index 85d574efebf2cdd9c29f3cf5c87ca3c185832fd0..9976517423aaf61d4aa6c97855dfed2795c1c63d 100644 (file)
@@ -7,24 +7,23 @@
                                                                                                                        
 --]]
 
-local first_line   = require("lain.helpers").first_line
-local newtimer     = require("lain.helpers").newtimer
-local naughty      = require("naughty")
-local wibox        = require("wibox")
-local math         = { abs    = math.abs,
-                       floor  = math.floor,
-                       log10  = math.log10,
-                       min    = math.min }
-local string       = { format = string.format }
-local ipairs       = ipairs
-local type         = type
-local tonumber     = tonumber
-local setmetatable = setmetatable
+local first_line = require("lain.helpers").first_line
+local newtimer   = require("lain.helpers").newtimer
+local naughty    = require("naughty")
+local wibox      = require("wibox")
+local math       = { abs    = math.abs,
+                     floor  = math.floor,
+                     log10  = math.log10,
+                     min    = math.min }
+local string     = { format = string.format }
+local ipairs     = ipairs
+local type       = type
+local tonumber   = tonumber
 
 -- Battery infos
 -- lain.widget.bat
 
-local function worker(args)
+local function factory(args)
     local bat       = { widget = wibox.widget.textbox() }
     local args      = args or {}
     local timeout   = args.timeout or 30
@@ -179,4 +178,4 @@ local function worker(args)
     return bat
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index eec14e75074fd6b41428156fe9975c153af30fbe..d3e8d4be7b9072a0ed6f26737a62672434dc07e7 100644 (file)
@@ -98,7 +98,7 @@ function calendar.attach(widget)
                                          awful.button({ }, 5, function () calendar.show(0,  1) end)))
 end
 
-local function worker(args)
+local function factory(args)
     local args                   = args or {}
     calendar.cal                 = args.cal or "/usr/bin/cal"
     calendar.attach_to           = args.attach_to or {}
@@ -117,4 +117,4 @@ local function worker(args)
     for i, widget in ipairs(calendar.attach_to) do calendar.attach(widget) end
 end
 
-return setmetatable(calendar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(calendar, { __call = function(_, ...) return factory(...) end })
index 94076c85b6f9e72721f2380a5012f697c0a3afa5..ed3aef213012d3cca1131949bdbfcffb0a707617 100644 (file)
@@ -21,7 +21,7 @@ local setmetatable = setmetatable
 -- lain.widget.contrib.gpmdp
 local gpmdp = {}
 
-local function worker(args)
+local function factory(args)
     local args          = args or {}
     local timeout       = args.timeout or 2
     local notify        = args.notify or "off"
@@ -89,4 +89,4 @@ local function worker(args)
     return gpmdp
 end
 
-return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end })
+return setmetatable(gpmdp, { __call = function(_, ...) return factory(...) end })
index 9d1e70306545151875d21c2ed5a81dc9810cd809..d7f130ebfe1a970dfcee8b2434876e7d28f11acf 100644 (file)
@@ -14,6 +14,6 @@
 local wrequire     = require("lain.helpers").wrequire
 local setmetatable = setmetatable
 
-local widgets = { _NAME = "lain.widget.contrib" }
+local widget = { _NAME = "lain.widget.contrib" }
 
-return setmetatable(widgets, { __index = wrequire })
+return setmetatable(widget, { __index = wrequire })
index 176f73a577473d4ae5bf4c35e9bc26b6797a0fa6..e0fdbc0652dcb53ad8958640feaa8f0fa6bf6064 100644 (file)
@@ -16,52 +16,50 @@ local setmetatable = setmetatable
 
 -- Keyboard layout switcher
 -- lain.widget.contrib.kblayout
-local kbdlayout = {}
-
-local function worker(args)
-   local args             = args or {}
-   local layouts          = args.layouts or {}
-   local settings         = args.settings or function () end
-   local add_us_secondary = true
-   local timeout          = args.timeout or 5
-   local idx              = 1
-
-   if args.add_us_secondary == false then add_us_secondary = false end
-
-   kbdlayout.widget = wibox.widget.textbox()
-
-   local function kbd_run_settings(layout, variant)
-      kbdlayout_now = {
-          layout  = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
-          variant = variant
-      }
-      widget = kbdlayout.widget
-      settings()
-   end
-
-   function kbdlayout.update()
-      helpers.async("setxkbmap -query", function(status)
-          kbd_run_settings(string.match(status, "layout:%s*([^\n]*)"),
-          string.match(status, "variant:%s*([^\n]*)"))
-      end)
-   end
-
-   function kbdlayout.set(i)
-      if #layouts == 0 then return end
-      idx = ((i - 1) % #layouts) + 1 -- Make sure to wrap around as needed.
-      local to_execute = "setxkbmap " .. layouts[idx].layout
-
-      if add_us_secondary and not string.match(layouts[idx].layout, ",?us,?") then
-         to_execute = to_execute .. ",us"
-      end
-
-      if layouts[idx].variant then
-         to_execute = to_execute .. " " .. layouts[idx].variant
-      end
 
-      if execute(to_execute) then
-         kbd_run_settings(layouts[idx].layout, layouts[idx].variant)
-      end
+local function factory(args)
+    local kbdlayout       = { widget = wibox.widget.textbox() }
+    local args             = args or {}
+    local layouts          = args.layouts or {}
+    local settings         = args.settings or function () end
+    local add_us_secondary = true
+    local timeout          = args.timeout or 5
+    local idx              = 1
+
+    if args.add_us_secondary == false then add_us_secondary = false end
+
+    local function kbd_run_settings(layout, variant)
+        kbdlayout_now = {
+            layout  = string.match(layout, "[^,]+"), -- Make sure to match the primary layout only.
+            variant = variant
+        }
+        widget = kbdlayout.widget
+        settings()
+    end
+
+    function kbdlayout.update()
+        helpers.async("setxkbmap -query", function(status)
+            kbd_run_settings(string.match(status, "layout:%s*([^\n]*)"),
+            string.match(status, "variant:%s*([^\n]*)"))
+        end)
+    end
+
+    function kbdlayout.set(i)
+        if #layouts == 0 then return end
+        idx = ((i - 1) % #layouts) + 1 -- Make sure to wrap around as needed.
+        local to_execute = "setxkbmap " .. layouts[idx].layout
+
+        if add_us_secondary and not string.match(layouts[idx].layout, ",?us,?") then
+            to_execute = to_execute .. ",us"
+        end
+
+        if layouts[idx].variant then
+            to_execute = to_execute .. " " .. layouts[idx].variant
+        end
+
+        if execute(to_execute) then
+            kbd_run_settings(layouts[idx].layout, layouts[idx].variant)
+        end
    end
 
    function kbdlayout.next() kbdlayout.set(idx + 1) end
@@ -77,4 +75,4 @@ local function worker(args)
    return kbdlayout
 end
 
-return setmetatable({}, { __call = function (_, ...) return worker(...) end })
+return factory
index fda50fc3f79b7db635b3b47d5be533ac55c1c007..f841e31add30a4bed3b5a669d464e917d6907260 100644 (file)
@@ -21,7 +21,7 @@ local setmetatable = setmetatable
 -- lain.widget.contrib.moc
 local moc = {}
 
-local function worker(args)
+local function factory(args)
     local args          = args or {}
     local timeout       = args.timeout or 2
     local music_dir     = args.music_dir or os.getenv("HOME") .. "/Music"
@@ -98,4 +98,4 @@ local function worker(args)
     return moc
 end
 
-return setmetatable(moc, { __call = function(_, ...) return worker(...) end })
+return setmetatable(moc, { __call = function(_, ...) return factory(...) end })
index 3e3b3a3c973802d9bd16443a9e7706ee770bbe0d..e8a6c9c1bbade3550f884f61a6fd6f5cfdeb498f 100644 (file)
@@ -19,7 +19,7 @@ local setmetatable = setmetatable
 -- lain.widget.cpu
 local cpu = { core = {} }
 
-local function worker(args)
+local function factory(args)
     local args     = args or {}
     local timeout  = args.timeout or 2
     local settings = args.settings or function() end
@@ -79,4 +79,4 @@ local function worker(args)
     return cpu
 end
 
-return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
+return setmetatable(cpu, { __call = function(_, ...) return factory(...) end })
index 652fa8ab38579411664170237094bb8a741ee495..49345ca3138603dede7d47a1b2e00d5e85c3c7fb 100644 (file)
@@ -7,15 +7,12 @@
 --]]
 
 local helpers      = require("lain.helpers")
-
 local shell        = require("awful.util").shell
 local focused      = require("awful.screen").focused
 local wibox        = require("wibox")
 local naughty      = require("naughty")
-
 local string       = string
 local tonumber     = tonumber
-
 local setmetatable = setmetatable
 
 -- File system disk space usage
@@ -45,7 +42,7 @@ function fs.show(seconds, scr)
     })
 end
 
-local function worker(args)
+local function factory(args)
     local args             = args or {}
     local timeout          = args.timeout or 600
     local partition        = args.partition or "/"
@@ -127,4 +124,4 @@ local function worker(args)
     return fs
 end
 
-return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
+return setmetatable(fs, { __call = function(_, ...) return factory(...) end })
index 1049d03e2112c212d9a854d48a1754e80c62a50c..0f7fde56ca1ea384a2fa4c12a76047c3be42a88f 100644 (file)
@@ -6,19 +6,18 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local naughty      = require("naughty")
-local wibox        = require("wibox")
-local string       = { format = string.format,
-                       gsub   = string.gsub }
-local type         = type
-local tonumber     = tonumber
-local setmetatable = setmetatable
+local helpers  = require("lain.helpers")
+local naughty  = require("naughty")
+local wibox    = require("wibox")
+local string   = { format = string.format,
+                   gsub   = string.gsub }
+local type     = type
+local tonumber = tonumber
 
 -- Mail IMAP check
 -- lain.widget.imap
 
-local function worker(args)
+local function factory(args)
     local imap      = { widget = wibox.widget.textbox() }
     local args      = args or {}
     local server    = args.server
@@ -84,4 +83,4 @@ local function worker(args)
     return imap
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index 9619d795d539911cae24921fd4777938b1d4d481..f77f872314a01f855adb1e79e3552cab9582b201 100644 (file)
@@ -15,6 +15,6 @@
 local wrequire     = require("lain.helpers").wrequire
 local setmetatable = setmetatable
 
-local widgets = { _NAME = "lain.widget" }
+local widget = { _NAME = "lain.widget" }
 
-return setmetatable(widgets, { __index = wrequire })
+return setmetatable(widget, { __index = wrequire })
index 74ebad01a5132f3a5c18640b7f91848675477da7..cf0d314fe350e08a37430467cd79e522d452b782 100644 (file)
@@ -18,7 +18,7 @@ local setmetatable = setmetatable
 -- lain.widget.mem
 local mem = {}
 
-local function worker(args)
+local function factory(args)
     local args     = args or {}
     local timeout  = args.timeout or 2
     local settings = args.settings or function() end
@@ -53,4 +53,4 @@ local function worker(args)
     return mem
 end
 
-return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
+return setmetatable(mem, { __call = function(_, ...) return factory(...) end })
index b5281b0f2f6fc6b2d48ed6bb81a03ac7c8d88261..88b993711d51bb569df73e51be5e70b66514454f 100644 (file)
@@ -23,7 +23,7 @@ local setmetatable = setmetatable
 -- lain.widget.mpd
 local mpd = {}
 
-local function worker(args)
+local function factory(args)
     local args          = args or {}
     local timeout       = args.timeout or 2
     local password      = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
@@ -134,4 +134,4 @@ local function worker(args)
     return mpd
 end
 
-return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
+return setmetatable(mpd, { __call = function(_, ...) return factory(...) end })
index c6ebaca9d5a9616b9da71e5fb4d489a04bddb206..a4b8c34b014bca2e31ce1bc5939acfc4a67d613a 100644 (file)
@@ -7,17 +7,16 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local naughty      = require("naughty")
-local wibox        = require("wibox")
-local string       = { format = string.format,
-                       match  = string.match }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local naughty = require("naughty")
+local wibox   = require("wibox")
+local string  = { format = string.format,
+                  match  = string.match }
 
 -- Network infos
 -- lain.widget.net
 
-local function worker(args)
+local function factory(args)
     local net = { widget = wibox.widget.textbox() }
     net.last_t = 0
     net.last_r = 0
@@ -120,4 +119,4 @@ local function worker(args)
     return net
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index 44694d1773449dcd546fdd416c313a4315947c09..6c1344d7539f44dbb65fb8f54fb9dc6645bd3d83 100644 (file)
@@ -6,18 +6,17 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local shell        = require("awful.util").shell
-local wibox        = require("wibox")
-local string       = { gmatch = string.gmatch,
-                       match  = string.match,
-                       format = string.format }
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local shell   = require("awful.util").shell
+local wibox   = require("wibox")
+local string  = { gmatch = string.gmatch,
+                  match  = string.match,
+                  format = string.format }
 
 -- PulseAudio volume
 -- lain.widget.pulseaudio
 
-local function worker(args)
+local function factory(args)
     local pulseaudio = { widget = wibox.widget.textbox() }
     local args        = args or {}
     local devicetype  = args.devicetype or "sink"
@@ -59,4 +58,4 @@ local function worker(args)
     return pulseaudio
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index fede5ba67bc5cf8a9020c625447612b10c94f615..caaffdc0a9bee9c2d1fb73d5209d80e03b9fe998 100644 (file)
@@ -33,7 +33,7 @@ local pulsebar = {
     _muted         = false
 }
 
-local function worker(args)
+local function factory(args)
     local args       = args or {}
     local timeout    = args.timeout or 5
     local settings   = args.settings or function() end
@@ -145,4 +145,4 @@ local function worker(args)
     return pulsebar
 end
 
-return setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end })
+return setmetatable(pulsebar, { __call = function(_, ...) return factory(...) end })
index ada349c82bf5899ba969621283ae559a1a423129..d7422d855a8efaba984397af922b5da6f8aa73a6 100644 (file)
@@ -17,7 +17,7 @@ local setmetatable = setmetatable
 -- lain.widget.sysload
 local sysload = {}
 
-local function worker(args)
+local function factory(args)
     local args     = args or {}
     local timeout  = args.timeout or 2
     local settings = args.settings or function() end
@@ -40,4 +40,4 @@ local function worker(args)
     return sysload
 end
 
-return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
+return setmetatable(sysload, { __call = function(_, ...) return factory(...) end })
index b66234603b82ce0576eebb58dff44c9606aa89a7..8e3bc3c37e11b616dc8f2c2b3e1026b63e3e54f9 100644 (file)
@@ -16,7 +16,7 @@ local setmetatable = setmetatable
 -- lain.widget.temp
 local temp = {}
 
-local function worker(args)
+local function factory(args)
     local args     = args or {}
     local timeout  = args.timeout or 2
     local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
@@ -42,4 +42,4 @@ local function worker(args)
     return temp
 end
 
-return setmetatable(temp, { __call = function(_, ...) return worker(...) end })
+return setmetatable(temp, { __call = function(_, ...) return factory(...) end })
index 55226b92cb20e43f762a5378d9891246ba52459a..36118b8a3cd31031c5786aba975059d137190f9f 100644 (file)
@@ -6,15 +6,14 @@
                                                   
 --]]
 
-local helpers      = require("lain.helpers")
-local textbox      = require("wibox.widget.textbox")
-local setmetatable = setmetatable
+local helpers = require("lain.helpers")
+local textbox = require("wibox.widget.textbox")
 
 -- Template for asynchronous watcher widgets
 -- lain.widget.watch
 
-local function worker(args)
-    local watch     = {}
+local function factory(args)
+    local watch     = { widget = args.widget or textbox() }
     local args      = args or {}
     local timeout   = args.timeout or 5
     local nostart   = args.nostart or false
@@ -22,8 +21,6 @@ local function worker(args)
     local cmd       = args.cmd
     local settings  = args.settings or function() widget:set_text(output) end
 
-    watch.widget = args.widget or textbox()
-
     function watch.update()
         helpers.async(cmd, function(f)
             output = f
@@ -40,4 +37,4 @@ local function worker(args)
     return watch
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory
index 1b2e80f9f6051aa4e3a524666627de3359d68bfd..10981466179f600900ca27c56c04d931a780c1dd 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
@@ -171,4 +170,4 @@ local function worker(args)
     return weather
 end
 
-return setmetatable({}, { __call = function(_, ...) return worker(...) end })
+return factory