Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Neil Bothwick has bits and bytes firing from his neurons.
Q
I’ve been overcharged
I have a Lenovo Yoga laptop and it is often used with the charger connected for lengthy periods. My Android phone has an option to limit charging to 80%, in order to preserve battery life, and I was wondering whether something like this is available for my laptop, rather than spending hours with the charger plugged in and the battery at 100%.
Joe Andrews
A Modern laptops have pretty clever charge management, so when you hit 100%, charging is stopped, or reduced to a trickle. Where the damage is done is when you unplug, run the battery down a little, then charge to 100% again. It’s the last few per cent of charging that does the damage, hence the Android option to limit it to 80% – electric cars have similar settings. Recent Linux kernels can limit charging, as long as the hardware provides the information to do this.
The user program to manage this is called TLP and should be in your distro’s repositories. Check whether your hardware is supported by running: $ sudo tlp-stat -b
Look under supported features for charge threshold. Providing this is available, you can set about editing /etc/ tlp.confto suit your needs. You need two lines to set charging thresholds:
START_CHARGE_THRESH_BAT0=0 STOP_CHARGE_THRESH_BAT0=1
It is not possible to adjust the actual threshold on these Lenovo models, although for other laptops it may be possible. So, we set them to either 0 to disable the threshold or 1 to enable it. Although the setting says BAT0, it actually applies to all batteries, even if tlp-stat shows it to be BAT1.
TLP is run as a systemd service – to start it and enable it at boot, run: $ sudo systemctl enable --now tlp.service Your distro’s installer may have already taken care of this, but running it again does no harm. If you edit the configuration file while the service is running, do not use systemctl restart . Instead, run TLP to tell the running instance to reload its configuration: $ sudo tlp start
What happens when you do want a full charge before going out? The TLP command-line program can override any of the current settings, so the following allow your battery to charge to 100%: $ sudo tlp fullcharge The threshold is reset when you either reboot or run: $ sudo tlp setcharge TLP is capable of handling much more than battery thresholds, such as changing performance governors depending on whether you are running on battery or AC. The man page gives a brief description, but there is extensive documentation at https://linrunner.de/tlp/index.html.