From f42fe32d9965a50a6c7ecabdb8376d50668d15e4 Mon Sep 17 00:00:00 2001 From: Luca CPZ Date: Tue, 31 Jul 2018 12:35:59 +0200 Subject: [PATCH] widget.bat: add failsafe AC --- widget/bat.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/widget/bat.lua b/widget/bat.lua index 9d5b9ae..03f9a0c 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -33,7 +33,7 @@ local function factory(args) end bat.batteries = args.batteries or (args.battery and {args.battery}) or {} - bat.ac = args.ac + bat.ac = args.ac or "AC0" function bat.get_batteries() helpers.line_callback("ls -1 " .. pspath, function(line) @@ -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) -- 2.39.2