X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/89ae5308061ac828b4f5002ba77c069585b1e088..907529920f7db2fd602d2204cf2c4f7efbdd64e2:/widget/bat.lua diff --git a/widget/bat.lua b/widget/bat.lua index 8afd6a1..2fece7d 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -41,7 +41,7 @@ local function factory(args) if bstr then bat.batteries[#bat.batteries + 1] = bstr else - bat.ac = string.match(line, "AC%w+") -- fallback one might be wrong + bat.ac = string.match(line, "A%w+") or "AC0" end end) end @@ -109,12 +109,12 @@ local function factory(args) local rate_power = tonumber(helpers.first_line(bstr .. "/power_now")) -- energy_now(P)[uWh], charge_now(I)[uAh] - local energy_now = tonumber(helpers.first_line(bstr .. "/energy_now") or - helpers.first_line(bstr .. "/charge_now")) + local energy_now = tonumber(helpers.first_line(bstr .. "/energy_now") or + helpers.first_line(bstr .. "/charge_now")) -- energy_full(P)[uWh], charge_full(I)[uAh] - local energy_full = tonumber(helpers.first_line(bstr .. "/energy_full") or - helpers.first_line(bstr .. "/charge_full")) + local energy_full = tonumber(helpers.first_line(bstr .. "/energy_full") or + helpers.first_line(bstr .. "/charge_full")) local energy_percentage = tonumber(helpers.first_line(bstr .. "/capacity")) or math.floor((energy_now / energy_full) * 100) @@ -141,7 +141,7 @@ local function factory(args) bat_now.status = status end end - bat_now.ac_status = tonumber(helpers.first_line(string.format("%s%s/online", pspath, ac))) or "N/A" + bat_now.ac_status = tonumber(helpers.first_line(string.format("%s%s/online", pspath, bat.ac))) or "N/A" if bat_now.status ~= "N/A" then if bat_now.status ~= "Full" and sum_rate_power == 0 and bat_now.ac_status == 1 then