Fixed a bunch of typos and issues in syscontrol uevent update

This commit is contained in:
Yessiest 2022-09-04 21:08:41 +04:00
parent f8f500d306
commit 2031ca424e
1 changed files with 4 additions and 3 deletions

View File

@ -90,19 +90,19 @@ syscontrol.power_supply.read_attribs = function(dev_name)
end
local uevent_data = {}
local device = {
type = fhandler:read("*a"),
type = fhandler:read("*a"):match("%S*"),
full_path = "/sys/class/power_supply/"..dev_name,
name = dev_name
}
fhandler:close()
uevent:read("*a"):gsub("[^\n]+",function(line)
uevent_f:read("*a"):gsub("[^\n]+",function(line)
local key,value = line:match("^([^=]+)=([^=]*)")
if value:match("^%d+$") then
value = tonumber(value)
end
uevent_data[key] = value
end)
uevent:close()
uevent_f:close()
if device.type == "Battery" then
device.model = uevent_data.POWER_SUPPLY_MODEL_NAME or "N/A"
device.energy_full_design = uevent_data.POWER_SUPPLY_ENERGY_FULL_DESIGN
@ -117,6 +117,7 @@ syscontrol.power_supply.read_attribs = function(dev_name)
elseif device.type == "Mains" then
device.online = (uevent_data.POWER_SUPPLY_ONLINE == 1)
end
return device
else
return nil, err
end