onflapp/gs-desktop

BatMon sometimes finds the wrong battery

Closed this issue · 1 comments

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.
valr/cbatticon#40

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!