Jump to content

GNOME battery charge control


or1k

Recommended Posts

As someone who has to use a laptop for work, I keep my laptop plugged in 8 hours or more a day, 7 days a week. The laptop's battery during these days would discharge and charge, slowly degrading the battery because only the last ~ 20% would be charged and discharged. To remedy this issue some devices now have charge thresholds where a user or firmware can configure a charge limit to stop the battery from getting constantly charged.

The most commonly found solution is to set a stop charge limit at 80% of the battery capacity. (Green part is never charged)
image.png

Another approach is to set a start and stop charge threshold where the battery charges till for example 80% but will only start when below 60%. The 60-80% region marks a "charge free zone". This is ideal for users who keep their laptop plugged in 24/7.
image.png
 

The Linux kernel supports these kinds of charge thresholds via a sysfs interface /sys/class/power_supply/BAT*/charge_control_{start,end}_threshold depending on hardware and driver support. Users can set their own charge control thresholds by echoing a value between 0-100 to the sysfs entry via for example a systemd unit or using a tool such as TLP.

That is usable for power users who know what thresholds to set and who also remember to turn it off when you for travel for a longer period of time and want to make full use of your battery. As a GNOME user however I would like to have a visual indication that my battery is being charge limited and an easy switch to turn this on and off.

GNOME obtains devices battery information in the shell and GNOME settings via UPower, a daemon which runs in the background and exposes device information from sysfs to DBus. UPower is also used by other popular DE's such as Cinnamon, Phosh, Mate, Lxqt, Xfce and Deepin.

My merge request for UPower implements detecting if a battery supports charge limits (start and stop) and allows for enabling set limits via a DBus method on the battery object. The limits are configurable via hwdb as UPower sets known good values 60-80% by default, users and vendors can override these limits with a simple hwdb rule.

For GNOME's settings, this merge request implements the UI design from Allan Day as can be seen below. (note: the label still needs some changes)
image.png
For those interested, I will be giving a presentation at FOSDEM in the Kernel devroom with more technical details. In the future I plan to work on a visual indicator in the GNOME Shell when charge limiting is enabled, implementing battery calibration and exposing charge thresholds on the Framework laptop.

 

Link to comment
Share on other sites

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
  • Create New...

Important Information

By using this site you automatically agree to the Privacy Policy | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.