Merge remote-tracking branch 'origin/develop' into ashpie-edits
# Conflicts: # config.lua # theme.lua
This commit is contained in:
commit
8c8d729395
@ -34,6 +34,15 @@ local bars = wibox.widget {
|
|||||||
layout = wibox.layout.flex.horizontal
|
layout = wibox.layout.flex.horizontal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fileExists(name)
|
||||||
|
local f = io.open(name, "r")
|
||||||
|
if f ~= nil then
|
||||||
|
io.close(f)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function readCommand(command)
|
function readCommand(command)
|
||||||
local handle = io.popen(command, "r")
|
local handle = io.popen(command, "r")
|
||||||
local r = handle:read("*a")
|
local r = handle:read("*a")
|
||||||
@ -151,8 +160,13 @@ 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 fileExists("/sys/class/power_supply/" .. b .. "/energy_now") then
|
||||||
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")
|
||||||
|
else
|
||||||
|
charge = charge + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_now")
|
||||||
|
capacity = capacity + readCommand("cat /sys/class/power_supply/" .. b .. "/charge_full")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return charge / capacity
|
return charge / capacity
|
||||||
|
Loading…
Reference in New Issue
Block a user