Implement feature aiming at governing battery charge control end threshold
Gnome v.: 41.3. Kernel v.: 5.16.x
-
Conventions in regard to the following expressions:
- battery life – amount of time a device runs before it needs to be recharged.
- battery lifespan – amount of time a battery lasts until it needs to be replaced.
-
Preamble
Lithium-ion rechargeable battery of a computer whose adapter is plugged in electric network is exposed to constant charging. As a consequence that leads to premature expiration and bloating. This type of battery becomes less effective as it gets older, nevertheless time is not the unique factor age is determined by. Its lifespan depends on its chemical age, which is affected by factors such as its temperature history and charging pattern. As battery ages chemically, its charging capacity gets smaller. In that context maximizing both battery life and lifespan should be a desirable goal both for the OS and user.
Vendors who have been motivated to seek for means to diminish above depicted phenomenon are untill now so few that they deserve a mention:
- Apple – for its own macOS line models.
- For Windows – Lenovo (February 2018), HP (business notebooks only, which is a major restriction. November 2018), Dell, ASUS, Acer and MSI, each developing drivers dedicated to mitigate the exposure of the notebook battery to key factors that can accelerate battery degradation and swelling over time.
For each of those vendors the feature is currently available on a selection of model of computers. Drivers implementing that feature may either acts on BIOS Legacy/BIOS UEFi or as a standalone application. One of its main function, if not the unique one, is to trigger the interruption of the battery charge when that last has reached a predefined value*, in order to preserve battery’s overall longevity.
(*) Value in percent, optimized for that use-case: 56.25–62.5.
On Linux, we notice the lack of counterpart of this feature for TLP, v. 1.4.0 which is presently the application Slimbook Battery 4 relies on to provide functions related to power. Nevertheless, for supported computer model, a procedure that has not yet been documented by the Gnome project and made available to the public, suits that purpose:
(*) Solely targeting OSs Debian and its derivatives
- Steps to reproduce on Arch Linux or Fedora to activate that feature. (Value applied: 60)
-
- For a transient effect:
# echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold
- For a permanent effect:
- For a transient effect:
# cd /etc/systemd/system/; touch battery_charge_control_end_threshold.service
# nano battery_charge_control_end_threshold.service
- To be added into the file:
[Unit]
Description=battery charge control end threshold
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
[Install]
WantedBy=multi-user.target
- The execution of the following command is optional; however it may be needed:
# restorecon -v /usr/lib/systemd/system/*.service
- Enable the created service
# systemctl --now enable battery_charge_control_end_threshold
- Proposal for improvement
An interpretation within your code of those commands, aiming to bring that feature as part of the existing relevant Gnome graphical tool, would at last, despite being so delayed, allow Linux to dully compete in this regard with those above mentioned OSs when served by those above mentioned vendors.