Package: battery-stats
Version: 0.5.6-3
Severity: normal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Dear Maintainer,

I have installed battery-stats on Debian bookworm on my Librem 5
and noticed that the "Battery Charge Graph" was showing an empty plot.

Further /var/log/battery-stats did not contain anything useful.
So I updated the existing patch that fixed #998418.

Please find my patch attached below, or on salsa:
https://salsa.debian.org/debian/battery-stats/-/merge_requests/2

Note, that I did not explicitly test on any laptop.


*** ./0001-Update-patch-adding-more-power-supplies.patch
- From 3a66fa24bd80a4a1902457ef624dec1ee07f64ee Mon Sep 17 00:00:00 2001
From: Evangelos Ribeiro Tzaras <[email protected]>
Date: Sat, 3 Jun 2023 03:30:43 +0200
Subject: [PATCH] Update patch adding more power supplies

Chargers and Batteries on the L5 are not recognized
(because they do not use BAT0, AC, ..)

$ ls /sys/class/power_supply
bq25890-charger  max170xx_battery  tps6598x-source-psy-0-003f

This update considers $foo a battery
if it's /sys/class/power_supply/$foo/type reads "Battery".
And $foo is considered a charger
if it exposes the file /sys/class/power_supply/$foo/online
- ---
 ...1000-add-more-power-supplies-support.patch | 40 +++++++++++++------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/debian/patches/1000-add-more-power-supplies-support.patch 
b/debian/patches/1000-add-more-power-supplies-support.patch
index d9aac0a..5b5bda9 100644
- --- a/debian/patches/1000-add-more-power-supplies-support.patch
+++ b/debian/patches/1000-add-more-power-supplies-support.patch
@@ -1,15 +1,19 @@
- -Description: Add support for more power supplies
- - Depending on the computer, a different power_supply name can be used.
- - Add support for more power supplies and use a loop to factorize code.
- -Author: Nicolas Schodet <[email protected]>
+From: Nicolas Schodet <[email protected]>
+Date: Sat, 3 Jun 2023 03:06:04 +0200
+Subject: Add support for more power supplies
+
 Bug-Debian: 998412
 
+Depending on the computer, a different power_supply name can be used.
+Add support for more power supplies and use a loop to factorize code.
+
+Last-Updated: 2023-06-03
 ---
- - src/battery-stats-collector | 15 ++++++++-------
- - 1 file changed, 8 insertions(+), 7 deletions(-)
+ src/battery-stats-collector | 19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
 
 diff --git a/src/battery-stats-collector b/src/battery-stats-collector
- -index 8e3cff7..c5d054a 100755
+index 8e3cff7..d20b828 100755
 --- a/src/battery-stats-collector
 +++ b/src/battery-stats-collector
 @@ -22,13 +22,14 @@ get_logline() {
@@ -24,13 +28,25 @@ index 8e3cff7..c5d054a 100755
 -        aconline=$(cat /sys/class/power_supply/ADP1/online)
 -    else
 +    aconline=notfound
- -+    for ac in AC AC0 ACAD ADP0 ADP1; do
- -+        if [ -f /sys/class/power_supply/$ac/online ]; then
- -+            aconline=$(cat /sys/class/power_supply/$ac/online)
- -+            break
- -+        fi
++    for ac in /sys/class/power_supply/*; do
++      if [ -f "$ac/online" ]; then
++          aconline=$(cat "$ac/online")
++          break
++      fi
 +    done
 +    if [ notfound = "$aconline" ]; then
          echo "No power supply found"
      fi
  
+@@ -40,8 +41,10 @@ get_logline() {
+ 
+     now="energy_now"
+     full="energy_full"
+-    for f in /sys/class/power_supply/BAT*; do
++    for f in /sys/class/power_supply/*; do
+         [ -e "$f" ] || continue
++      [ -f "$f/type" ] || continue
++      [ "Battery" = $(cat "$f/type") ] || continue
+         if [ ! -e $f/$now ] ; then now="charge_now"; fi
+         if [ ! -e $f/$full ] ; then full="charge_full"; fi
+         energy_now=$(cat $f/$now) # uWh
- -- 
2.40.1



- -- System Information:
Debian Release: 12.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 
'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: arm64, i386

Kernel: Linux 6.1.0-9-amd64 (SMP w/32 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages battery-stats depends on:
ii  bc                         1.07.1-3+b1
ii  gzip                       1.12-1
ii  init-system-helpers        1.65.2
ii  logrotate                  3.21.0-1
ii  lsb-base                   11.6
ii  sysvinit-utils [lsb-base]  3.06-4

Versions of packages battery-stats recommends:
ii  gnuplot-nox [gnuplot]  5.4.4+dfsg1-2+b2
ii  libtext-csv-perl       2.02-2
ii  python3                3.11.2-1+b1
ii  python3-matplotlib     3.6.3-1+b1

battery-stats suggests no packages.

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEuThlVLfdJmvLjimpkPDJsYprShkFAmR6sYUACgkQkPDJsYpr
Shn2cA//XC8nxDaAlb8G0NvjNQW6E/TnzCmv3u4ytsqz9uNp6GKtW9uwib90iAg+
99ReQso6Qn8mGHbOoXMqzA+jwDh9uhPuuwuFaij5bk0HqqxLI60XHwsvTnQbM0mZ
ALi9qNdHYWKPTIB/EPlN7xDjYJZUQmmr/ONfzL1G2juqg3KfEH7ATdSmc17iMkJb
h7oARkKoAOkB0UufKrPLImLMDTHCsCovn46ok8HysKPKEIluFz15wPA9xcSxPcHj
pEs4sfgdi9KmT4/OkRpI3plZCBZC6vpk1Fe6hARosNSrOEgPs6lFNJLZr5oJDknv
IUZ4ANkEdZZmSzMEaFw5NwXlYTjGEHsnUZKwAhmJAt2rralTnJpy2Cuc2C9QKKYx
5UneoG/d0cKUVPFkYItvNgy2Pr/wWtfTS7GrszoKNZp8Q5LTDkXOeZT/zsfuPlDd
SC7Ap/HD2zAKUvtBqCRccGmyz9GDbJINaTaNUabMCXFFmv6bL9ACovsD0QK0ET27
18vu1CnzrYeHzNfuuQ0r3VQTkVuCiTSVueY2ugd/O8YtGiKLAy6gsKZ7AzYV/BQ1
b6gKBmrjUyu2xSSqiDM2wllmGFm2XV9NvEaFcCmmkzLYdtr8fBT8hGCgiv28l7BO
6OmkklxENSR4AuFk0FU2uCcomh3ohGIZK1NTLnaQZ1/5IxNvde8=
=2RFk
-----END PGP SIGNATURE-----

Reply via email to