From: Luke Bonham Date: Wed, 11 Jan 2017 16:40:10 +0000 (+0100) Subject: Merge pull request #262 from sim590/multiple-batteries-status X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/00b0609e34dfa69ed889f2e9e557f5b9b80589c1?hp=617675d6c3a7b79d650bfcd52a3c13e8dcdfa459 Merge pull request #262 from sim590/multiple-batteries-status bat: redefine battery status with multiple batteries --- diff --git a/widgets/bat.lua b/widgets/bat.lua index 8e483f7..38104b5 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -108,7 +108,16 @@ local function worker(args) end end + -- When one of the battery is charging, others' status are either + -- "Full", "Unknown" or "Charging". When the laptop is not plugged in, + -- one or more of the batteries may be full, but only one battery + -- discharging suffices to set global status to "Discharging". bat_now.status = bat_now.n_status[1] + for _,status in ipairs(bat_now.n_status) do + if status == "Discharging" or status == "Charging" then + bat_now.status = status + end + end bat_now.ac_status = tonumber(first_line(string.format("%s%s/online", pspath, ac))) or "N/A" if bat_now.status ~= "N/A" then