Skip to content

Commit

Permalink
Add vicious.change_timer: a helper to change the timeout
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
blueyed committed Mar 18, 2021
1 parent 150864a commit f25866f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,16 @@ function vicious.call_async(wtype, format, warg, callback)
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
-- }}}

0 comments on commit f25866f

Please sign in to comment.