Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/sys/class/power_supply/* is too broad a search, suggest scanning just /sys/class/power_supply/BAT* #207

Open
BillyCroan opened this issue Jan 21, 2024 · 0 comments

Comments

@BillyCroan
Copy link

If your laptop has a peripheral device with a battery, laptop-mode-tools reacts as if that devices battery is the laptop's and reacts poorly when that peripheral doesn't support a design_capacity. I was getting tonnes of this in my syslog:

2024-01-14T20:49:11.499724-06:00 x360 laptop_mode[1483528]: WARNING: Battery does not report a capacity. Minimum battery
2024-01-14T20:49:11.502666-06:00 x360 laptop_mode[1483528]: charge checking does not work without a design capacity.
2024-01-14T20:49:11.502742-06:00 x360 laptop_mode[1483528]: WARNING: Battery does not report a design capacity. Auto hibernation
2024-01-14T20:49:11.502781-06:00 x360 laptop_mode[1483528]: does not work without a design capacity.
2024-01-14T20:49:11.502812-06:00 x360 laptop_mode[1483528]: You seem to have a broken battery
2024-01-14T20:49:11.502838-06:00 x360 laptop_mode[1483528]: Cannot determine design_capacity_warning
2024-01-14T20:49:11.502876-06:00 x360 laptop_mode[1483528]: Disabling hibernation
2024-01-14T20:49:11.502942-06:00 x360 laptop_mode[1483528]: Failed to determine battery charge. Battery charge units are not in
2024-01-14T20:49:11.502976-06:00 x360 laptop_mode[1483528]: mWh, uWh, mAh or uAh.
2024-01-14T20:49:11.503002-06:00 x360 laptop_mode[1483528]: Laptop mode
2024-01-14T20:49:11.503221-06:00 x360 laptop_mode[1483528]: enabled, active [unchanged]
2024-01-14T20:49:11.503282-06:00 x360 systemd[1]: Reloaded laptop-mode.service - Laptop Mode Tools.

This is because line750:
for BATT in /sys/class/power_supply/* ; do

That captures all batteries, when I think we're really looking for BAT0. and maybe some laptops have a BAT1 or 2

What you don't want is to match on hid-0018:04F3:272D.0002-battery or the like

So I edited like 750 to:
for BATT in /sys/class/power_supply/BAT* ; do

And now my syslog is much happier. no more angry messages.

If you really don't want to narrow * down to BAT* then perhaps check on like 751 that BATT does not begin with "hid-"

I hope this bug report helps other users who were having the broken battery warnings, and helps improve the laptop-mode-tools project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant