diff options
Diffstat (limited to 'util/widgets.lua')
-rw-r--r-- | util/widgets.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/util/widgets.lua b/util/widgets.lua index 301f25b..eae351d 100644 --- a/util/widgets.lua +++ b/util/widgets.lua @@ -3,17 +3,21 @@ local gears = require("gears") local widgets = {} -function widgets.watchfn(callback, timeout, base_widget) - local widget = (base_widget or wibox.widget.textbox)() - gears.timer({ +function widgets.add_timer(w, callback, timeout) + w._timer = gears.timer({ timeout = timeout or 5, call_now = true, autostart = true, callback = function() - callback(widget) + callback(w) end }) - return widget + return w +end + +function widgets.watchfn(callback, timeout, base_widget) + local widget = (base_widget or wibox.widget.textbox)() + return widgets.add_timer(widget, callback, timeout) end return widgets |