Fixed battery widget opening missing file

This commit is contained in:
Lucas Hernán Tarche 2021-07-03 16:41:03 -03:00
parent 662a816dd0
commit 7ed0fc7522

View File

@ -151,10 +151,15 @@ function getBatteryCapacity()
local capacity = 0 local capacity = 0
for b in getBatteries() do for b in getBatteries() do
if b:sub(1,3) ~= 'hid' and readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then if b:sub(1,3) ~= 'hid' and readCommand("cat /sys/class/power_supply/" .. b .. "/type"):match("Battery") then
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") charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_now")
capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full") capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/energy_full")
end end
end end
end
return charge / capacity return charge / capacity
end end