onflapp / gs-desktop

GNUstep Desktop
https://onflapp.github.io/gs-desktop/index.html
MIT License
102 stars 7 forks source link

BatMon sometimes finds the wrong battery #28

Closed mclarenlabs closed 9 months ago

mclarenlabs commented 9 months ago

When BatMon is started and there is also a bluetooth wireless mouse attached, BatMon will sometimes try to report on that battery, rather than the main laptop battery.

On Linux, BatMon looks ln /sys/class/power_supply. On my system it looks like this

$ ls -d /sys/class/power_supply/*
/sys/class/power_supply/AC
/sys/class/power_supply/BAT0
/sys/class/power_supply/hid-34:88:5d:91:9a:b6-battery

BatMon further looks for a file within each of those directories named "present" whose contents is the value "1"

$ ls /sys/class/power_supply/*/present
/sys/class/power_supply/BAT0/present
/sys/class/power_supply/hid-34:88:5d:91:9a:b6-battery/present

$ cat /sys/class/power_supply/*/present
1
1

BAT0 is the main battery, hid-34:88:5d:91:9a:b6-battery is the Logitech Bluetooth mouse.

One EASY workaround is to simply start BatMon with the mouse turned off.

This issue has also been recognized here, with a proposed fix. https://github.com/valr/cbatticon/issues/40

onflapp commented 9 months ago

I had to add additional check (type equals "Battery") to make it work on my notebook but I think this should be robust enough -- until something else comes out ;-)

Many thanks for your contribution!