* Petter Reinholdtsen <p...@hungry.com> [2021-11-03 23:10]: > [Nicolas Schodet] > > My system power supply is named AC0, but battery-stats-collector only > > looks at AC, ACAD or ADP1. > > > > An easy fix would be to add AC0 to the list. > Perhaps you can provide a patch?
Here it is. It replace the add-xps13-adapter-support patch on salsa. Also I noticed that there was an NMU, but the NMU is not on salsa and the history diverged. > What is the content of your /sys/class/power_supply/AC0/online? Right now, it’s 0, power supply is not connected. Nicolas.
From: Nicolas Schodet <n...@ni.fr.eu.org> Date: Thu, 4 Nov 2021 00:16:06 +0100 Subject: 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. --- src/battery-stats-collector | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/battery-stats-collector b/src/battery-stats-collector index 8e3cff7..c5d054a 100755 --- a/src/battery-stats-collector +++ b/src/battery-stats-collector @@ -22,13 +22,14 @@ get_logline() { secstamp=$(date +%s) stamp=$(date +"%Y/%m/%d %H:%M:%S") - if [ -f /sys/class/power_supply/AC/online ]; then - aconline=$(cat /sys/class/power_supply/AC/online) - elif [ -f /sys/class/power_supply/ACAD/online ]; then - aconline=$(cat /sys/class/power_supply/ACAD/online) - elif [ -f /sys/class/power_supply/ADP1/online ]; then - 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 + done + if [ notfound = "$aconline" ]; then echo "No power supply found" fi