From 40e8da039423b225a4fde3f539436ec5b84d1b30 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Wed, 31 Aug 2022 16:57:26 +0400 Subject: [PATCH] Made the battery disappear if there's nothing to show --- widgets/battery.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/widgets/battery.lua b/widgets/battery.lua index 7e5cc41..5bfc0aa 100644 --- a/widgets/battery.lua +++ b/widgets/battery.lua @@ -137,7 +137,7 @@ return function(args) end update_virtual_battery() -- Update loop - gears.timer({ + local power_update = gears.timer({ timeout = args.power_polling or 2, autostart = true, callback = function() @@ -205,7 +205,7 @@ return function(args) end end -- Update loop - gears.timer({ + local backlight_update = gears.timer({ timeout = args.backlight_polling or 2, autostart = true, callback = function() @@ -222,5 +222,11 @@ return function(args) end }) -- }}} + -- We don't need this widget if we don't have anything to show + if #widget_map == 0 then + backlight_update:stop() + power_update:stop() + return + end return battery_widget end