This guide will guide you on how to limit battery charge percentage in order to help extend the lifespan of your battery.
- Check if
upoweris installed$ upower --version
- If
upoweris 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-pathasBAT0$ upower --enumerate $ upower -d
- Create a new
udevrule 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
BAT0as our battery name and80as 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
udevrules and restart the service in order to apply changes
$ sudo udevadm control --reload-rules
$ sudo systemctl restart upower