From 2031ca424eac5f2b40584d6dac3c068a466abc53 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Sun, 4 Sep 2022 21:08:41 +0400 Subject: [PATCH] Fixed a bunch of typos and issues in syscontrol uevent update --- libs/syscontrol.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/syscontrol.lua b/libs/syscontrol.lua index 9e89b5d..f79a539 100644 --- a/libs/syscontrol.lua +++ b/libs/syscontrol.lua @@ -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