X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/8d3868d7ce528cfc075e246c8935bae2724e0868..a6ca6ab03005cb4fe944f4e4e56bf432ef1f3327:/widget/watch.lua?ds=sidebyside diff --git a/widget/watch.lua b/widget/watch.lua index 55226b9..36118b8 100644 --- a/widget/watch.lua +++ b/widget/watch.lua @@ -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