From 0d91a6e86cfa09fa3b60b6276f6b6415f4ae6f33 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 473e381..1ddcfd7 100644 --- a/init.lua +++ b/init.lua @@ -287,6 +287,17 @@ function vicious.call(myw, format, warg) 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 -- }}}