This guide will guide you on how to limit battery charge percentage in order to help extend the lifespan of your battery.
- Check if
upower
is installed$ upower --version
- If
upower
is not installed, install it and start the service$ sudo apt update $ sudo apt install upower $ sudo systemctl start upower
- List all the power devices present in the system. In most cases, your main battery should have the
native-path
asBAT0
$ upower --enumerate $ upower -d
- Create a new
udev
rule that will be executed every time we plug the power adaptor in our laptop$ sudo nano /etc/udev/rules.d/r_battery.rules
- Paste the following inside the rule file and save it. With this rule, we have
BAT0
as our battery name and80
as the charge limit value. Once the battery charge reaches 80%, it will halt the charging process and use the standby AC for power.SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/bin/sh -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'"
- Reload
udev
rules and restart the service in order to apply changes
$ sudo udevadm control --reload-rules
$ sudo systemctl restart upower