Draft: Initial support for UPower charge limit settings

Marking as draft until frameworks/solid!217 (closed) is merged and available in a released KF6 version. Apart from the dependency though, this MR works and is ready for review.

Following !253 and !290, here's some progress with BUG: 450551. In order to preserve charge limits across reboots, we want to use new(ish) UPower API which will set the configured charge threshold on every boot. In order to switch our users to UPower, from the current direct kernel access that requires a privileged KAuth helper, we need three things:

  1. Support for UPower in the "Power Management" KCM, as well as in the "Power and Battery" applet.
  2. UPower needs to support custom threshold values if we want to avoid regressing functionality and losing users' existing settings.
  3. A careful migration algorithm that reads existing threshold values (if previously set) from sysfs and migrates them to UPower.

This MR implements (1), and leaves (2) as well as (3) for later. It provides a new opt-in config option for ~/.config/powerdevilrc:

[BatteryManagement]
UseUPowerForChargeLimits=true

If enabled, and assuming the following two MRs are also applied, then Plasma will now make use of UPower instead of PowerDevil's own KAuth charge threshold helper to provide support for setting charge limits. Because migration is a bit hairy (see my earlier thoughts on that), we can't turn it on by default yet. But we can give users a manual option who have been pining for a way to auto-apply charge limits on boot. For the time being, let's label the option as experimental. There's no UI for it, and we'd rather not have one anyway.

Depends on plasma-workspace!5733 as well as frameworks/solid!217 (closed).

See individual commit messages for more details.

CC @ngraham, @root-core

Edited by Jakob Petsovits

Merge request reports

Loading