abase renamed to watch; #312: wiki updated

This commit is contained in:
copycat-killer 2017-02-08 14:09:52 +01:00
parent 33223f2816
commit c155301459
2 changed files with 11 additions and 11 deletions

View File

@ -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

@ -1 +1 @@
Subproject commit af671ad9bb1ce9c7bb74a75f489a3b5d0a934558
Subproject commit 32904a7e2cc20b9aec497aa9a031324fc535b0f9