Skip to content

daemon: Fix charge threshold support for Dell laptops, maybe more

Jakob Petsovits requested to merge work/jpetso/dell-charge-limits into master

Commit message

Some kernel drivers expose charge_types in addition to start/end charge thresholds for power supply batteries. A prominent example is the dell_laptop starting with Linux 6.12, which supports (at least some) Dell Latitude laptops.

This commit will attempt to write a charge type on Linux systems if the battery's charge_types file exists in sysfs. It will write Standard as charge type if the configuration asks for fully charging the laptop, and Custom for all other charge threshold values.

The KAuth helper also now supports writing explicitly provided charge types, however the settings UI does not make use of this yet.

This commit does not (yet) implement reading current or supported charge types, because that's not useful without a settings UI. Note that charge threshold settings are only applied when values are changed, so any pre-existing charge type (e.g. Fast) won't be touched without an explicit interaction.

BUG: 497200

Testing

I tested that this doesn't break charge limit settings on my ThinkPad laptop, which has /sys/class/power_supply/BAT0/charge_control_{start,end}_threshold files and no /sys/class/power_supply/BAT0/charge_types.

I do not have a laptop with charge_types available for testing here. Before merging, someone who owns such a laptop should make sure that this MR actually fixes the problem for them. Thanks!

Merge request reports

Loading