mirror of https://github.com/lcpz/lain.git
abase renamed to watch; #312: wiki updated
This commit is contained in:
parent
33223f2816
commit
c155301459
|
@ -10,11 +10,11 @@ local helpers = require("lain.helpers")
|
|||
local textbox = require("wibox.widget.textbox")
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Template for custom asynchronous widgets
|
||||
-- lain.widgets.abase
|
||||
-- Template for asynchronous watcher widgets
|
||||
-- lain.widgets.watch
|
||||
|
||||
local function worker(args)
|
||||
local abase = {}
|
||||
local watch = {}
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 5
|
||||
local nostart = args.nostart or false
|
||||
|
@ -22,22 +22,22 @@ local function worker(args)
|
|||
local cmd = args.cmd
|
||||
local settings = args.settings or function() widget:set_text(output) end
|
||||
|
||||
abase.widget = args.widget or textbox()
|
||||
watch.widget = args.widget or textbox()
|
||||
|
||||
function abase.update()
|
||||
function watch.update()
|
||||
helpers.async(cmd, function(f)
|
||||
output = f
|
||||
if output ~= abase.prev then
|
||||
widget = abase.widget
|
||||
if output ~= watch.prev then
|
||||
widget = watch.widget
|
||||
settings()
|
||||
abase.prev = output
|
||||
watch.prev = output
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
abase.timer = helpers.newtimer(cmd, timeout, abase.update, nostart, stoppable)
|
||||
watch.timer = helpers.newtimer(cmd, timeout, watch.update, nostart, stoppable)
|
||||
|
||||
return abase
|
||||
return watch
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit af671ad9bb1ce9c7bb74a75f489a3b5d0a934558
|
||||
Subproject commit 32904a7e2cc20b9aec497aa9a031324fc535b0f9
|
Loading…
Reference in New Issue