Skip to content

Commit 50dc101

Browse files
committed
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 <[email protected]>
1 parent 6997606 commit 50dc101

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

init.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ function vicious.call(myw, format, warg)
306306
end
307307
-- }}}
308308

309+
-- {{{ Change the timer of a registered widget.
310+
function vicious.change_timer(reg, timer_)
311+
if not reg then return end
312+
if timer_ ~= reg.timer then
313+
vicious.unregister(nil, true, reg)
314+
reg.timer = timer_
315+
regregister(reg)
316+
end
317+
end
318+
-- }}}
319+
309320
return vicious
310321

311322
-- }}}

0 commit comments

Comments
 (0)