Persist battery charge thresholds across reboots and resume

Many laptops (ASUS, some Lenovo, Samsung, etc.) reset the battery charge_control_end_threshold / charge_control_start_threshold sysfs values to hardware defaults on every power cycle or resume from suspend. PowerDevil currently only reads thresholds from sysfs but never restores them, so user-configured charge limits are silently lost after reboot.

This patch adds threshold persistence by:

  1. Adding ChargeStartThreshold / ChargeStopThreshold entries to PowerDevilGlobalSettings.kcfg (stored in powerdevilrc).

  2. On every readChargeThreshold() call, comparing the live sysfs values against the saved config. If they differ, the saved values are restored via the existing KAuth setthreshold helper. If they match, the config is updated to stay in sync with any KCM changes.

  3. Calling readChargeThreshold() on resume from suspend to catch hardware that resets thresholds during sleep.

No changes to the KCM, the KAuth helper, or the sysfs paths are needed - the fix is entirely within the daemon using existing infrastructure.

BUG: 450551

Tested on;

  • Asus Zephyrus 2025
  • KDE Neon Dev Unstable

Please test it on different brands.

Edited by Furkan Tokac

Merge request reports

Loading