From 29ae2ec2d413e2f788712eac3df372b4a5534fe5 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 6 Jul 2016 10:33:23 +0200 Subject: [PATCH] bat: type checking on perc #209 --- widgets/bat.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index e9ed928..2da5e2d 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -19,6 +19,7 @@ local math = { abs = math.abs, min = math.min } local string = { format = string.format } +local type = type local tonumber = tonumber local setmetatable = setmetatable @@ -74,6 +75,7 @@ local function worker(args) local sum_energy_full = 0 local sum_energy_percentage = 0 local pspath = "/sys/class/power_supply/" + pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery @@ -144,7 +146,7 @@ local function worker(args) settings() -- notifications for low and critical states - if notify == "on" and bat_now.perc and bat_now.status == "Discharging" then + if notify == "on" and type(bat_now.perc) == "number" and bat_now.status == "Discharging" then if bat_now.perc <= 5 then bat.id = naughty.notify({ preset = bat_notification_critical_preset, -- 2.39.5