Skip to content

Commit 0d91a6e

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 979cc46 commit 0d91a6e

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
@@ -287,6 +287,17 @@ function vicious.call(myw, format, warg)
287287
end
288288
-- }}}
289289

290+
-- {{{ Change the timer of a registered widget.
291+
function vicious.change_timer(reg, timer_)
292+
if not reg then return end
293+
if timer_ ~= reg.timer then
294+
vicious.unregister(nil, true, reg)
295+
reg.timer = timer_
296+
regregister(reg)
297+
end
298+
end
299+
-- }}}
300+
290301
return vicious
291302

292303
-- }}}

0 commit comments

Comments
 (0)