← Home

Set Laptop Battery Charging Thresholds in Linux

In windows laptops, you will often find an option to set a charging limit (charging threshold) to prevent battery degradation. Unfortunately, most laptops do not provide Linux support for this except for some such as Lenovo Thinkpads. In this article, I will explain how to check if your laptop has support for this under Linux and the process for setting up custom charging thresholds without relying on a utility like TLP.

Check support for battery charging thresholds

In Linux there is a corresponding directory for your battery under /sys/class/power_supply/. The first step is to find that directory. For that, you can use the following command.

ls --recursive /sys/class/power_supply/BAT*

In my case, I got the following output.

/sys/class/power_supply/BAT0

Next, you need to navigate into that directory and list files.

If you can see "threshold" related files similar to the screenshot above, your laptop has support for setting up custom charging thresholds.

Set custom charging thresholds

To set custom thresholds all you have to do is put the appropriate value in each threshold file.

For example, to start charging when capacity is at 80%, you can simply put "80" in the charge_control_start_threshold file.

Similarly, you can set when to stop charging using the charge_control_end_threshold file.

echo 90 > charge_control_start_threshold

This will make the laptop start charging at 80% and stop when it reaches 90%.

Do note that the content of these files gets reverted to the default values in every reboot. To make it permanent you can either set up a systemd service or a cronjob.

References

How to Set Battery Charging Threshold (Limit the Charging) In Thinkpad and Other Laptops in Linux/Unix