Add vicious.change_timer: a helper to change the timeout

This is useful in case you want to change the timeout value for a
registered widget, e.g. from the format callback function.

I am using this to have a shorter timeout interval for the temperature
widget when its value is above some threshold.

Signed-off-by: Daniel Hahler <git@thequod.de>
This commit is contained in:
Daniel Hahler 2015-07-19 17:47:44 +02:00
parent 150864a76d
commit f25866f4e5
1 changed files with 11 additions and 0 deletions

View File

@ -352,5 +352,16 @@ function vicious.call_async(wtype, format, warg, callback)
end end
-- }}} -- }}}
-- {{{ Change the timer of a registered widget.
function vicious.change_timer(reg, timer_)
if not reg then return end
if timer_ ~= reg.timer then
vicious.unregister(nil, true, reg)
reg.timer = timer_
regregister(reg)
end
end
-- }}}
return vicious return vicious
-- }}} -- }}}