tint3
tint3 copied to clipboard
Battery applet: support multiple batteries
battery applet can't find power_supply
.
How can I fix this?
The battery
applet looks for per-battery paths in sysfs: https://github.com/jmc-88/tint3/blob/8cf54fe8c1a0d1b8d05808ac3fd64e072b7d2c29/src/battery/linux_sysfs.cc#L8
- Does your kernel support it? (
CONFIG_SYSFS
) - Is it mounted? (if not,
mount -t sysfs sysfs /sys
) - What does it contain? (
ls -R /sys/class/power_supply
)
We can start from here and see what's wrong. And possibly I should add more useful error messages. :)
I now have:
# ls -R /sys/class/power_supply
/sys/class/power_supply:
AC0 BAT0 BAT1
tint3 only shows me the first,
but not the second?
Yes, multiple battery support is to do: https://github.com/jmc-88/tint3/blob/master/src/battery/battery.cc#L190
I didn't prioritize that as you're the first one to request support for it, and I don't have a device with two batteries to test this against. I'll keep this bug open to track that.
My understanding is that tint2 shows a single battery applet with the aggregated status, not separate battery applets. Can you confirm?
tint2 output:
Found mains "AC0"
tint2: Found power device BAT0
tint2: /y/src/panelapplets/tint2/src/battery/linux.c:155: read failed
tint2: Failed to initialize battery "BAT0"
tint2: Found power device BAT1
tint2: /y/src/panelapplets/tint2/src/battery/linux.c:155: read failed
tint2: Failed to initialize battery "BAT1"
If I may pitch in, I think it would be very useful for both projects (tint3 and tint2) to see the contents of /sys/class/power_supply
on your machine. The following command will save it to a file called battery.txt
:
bash -c "exec 1>battery.txt; exec 2>&1; for d in /sys/class/power_supply/* ; do find $d/ -exec sh -c 'echo {} ; cat {} ' ';' ; done"
Could you please post that here?
@jmc-88:
I have a script that converts this file back into a directory, and a couple of such directories here. Tint2 accepts the undocumented CLI argument --battery-sys-prefix
that replaces /sys/class/power_supply
with the given path, to test the code on that data.
That script never ended, producing endless output. I have an improvement for you:
cd /sys/devices/virtual/power_supply/ && grep -r ''
bat.zip
Thank you!
Regarding tint2, I fixed that problem with initializing the batteries. It was caused by not handling gracefully the lack of charging rate data (current) on your system.
I have also added to the repository your data files, in https://gitlab.com/o9000/tint2/tree/master/test/2battery-gijsbers Hopefully this will help with adding multi-battery support in tint3.