Skip to content

Commit f25866f

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 150864a commit f25866f

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
@@ -352,5 +352,16 @@ function vicious.call_async(wtype, format, warg, callback)
352352
end
353353
-- }}}
354354

355+
-- {{{ Change the timer of a registered widget.
356+
function vicious.change_timer(reg, timer_)
357+
if not reg then return end
358+
if timer_ ~= reg.timer then
359+
vicious.unregister(nil, true, reg)
360+
reg.timer = timer_
361+
regregister(reg)
362+
end
363+
end
364+
-- }}}
365+
355366
return vicious
356367
-- }}}

0 commit comments

Comments
 (0)