diff --git a/simple/widgets/system_resources.lua b/simple/widgets/system_resources.lua index b20592c..f338bcc 100644 --- a/simple/widgets/system_resources.lua +++ b/simple/widgets/system_resources.lua @@ -151,8 +151,13 @@ function getBatteryCapacity() local capacity = 0 for b in getBatteries() do if b:sub(1,3) ~= 'hid' and readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then - charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now") - capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full") + if type(readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now")) == "string" then + charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_now") + capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_full") + else + charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now") + capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full") + end end end return charge / capacity