From fea2bd24e83c90c311f4e77ccf46f1464a6f5afb Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 3 Nov 2024 16:09:10 -0600 Subject: update temp widget to be fancier and other small stuff --- util/widgets.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'util') 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 -- cgit v1.2.3