From ca221800498e88b68dd297dce3df622e98478a7d Mon Sep 17 00:00:00 2001 From: Stefano Mazzucco Date: Wed, 18 Dec 2019 10:50:10 +0000 Subject: [PATCH] Compute percentace in maybe_warn only if needed --- power_widget.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/power_widget.lua b/power_widget.lua index ba183a5..3801396 100644 --- a/power_widget.lua +++ b/power_widget.lua @@ -71,7 +71,6 @@ end local function maybe_warn(widget, warning_condition, notification_preset, message) local warning_level = device.warninglevel or "None" - local percentage = get_percentage() if warning_condition then local msg = message or (warning_level.name == "None" and "Low" or warning_level.name) .. " battery!" @@ -86,7 +85,7 @@ local function maybe_warn(widget, warning_condition, notification_preset, messag notification = naughty.notify({ preset = notification_preset, title = msg, - text = percentage .. "% remaining"}) + text = get_percentage() .. "% remaining"}) end end