]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

bat: find battery status when multiple batteries
authorSimon Désaulniers <sim.desaulniers@gmail.com>
Wed, 11 Jan 2017 05:15:23 +0000 (00:15 -0500)
committerSimon Désaulniers <sim.desaulniers@gmail.com>
Wed, 11 Jan 2017 16:00:47 +0000 (11:00 -0500)
Battery status was previously assumed to the first battery's status. This is
wrong as it doesn't support the case where the first battery is full and the
second is discharging, therefor showing battery percentage to 100% when the
actual battery percentage is lower.

widgets/bat.lua

index 8e483f75dd8a2127fd1c54541be0d731ab8dc8e4..38104b5c417f64f0f4db31bca53afa4322a8c1fe 100644 (file)
@@ -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