From: copycat-killer Date: Wed, 6 Jul 2016 08:33:23 +0000 (+0200) Subject: bat: type checking on perc #209 X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/29ae2ec2d413e2f788712eac3df372b4a5534fe5?ds=sidebyside;hp=--cc bat: type checking on perc #209 --- 29ae2ec2d413e2f788712eac3df372b4a5534fe5 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,