From f25866f4e57270610b0419761277a9ff2ef55de2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 19 Jul 2015 17:47:44 +0200 Subject: [PATCH] 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 --- init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init.lua b/init.lua index d8a293a..074d883 100644 --- a/init.lua +++ b/init.lua @@ -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 -- }}}