Skip to content

Instantly share code, notes, and snippets.

@estorgio
Last active February 24, 2025 05:28
Show Gist options
  • Save estorgio/4673bad1c1201dc57efd69f018c30cab to your computer and use it in GitHub Desktop.
Save estorgio/4673bad1c1201dc57efd69f018c30cab to your computer and use it in GitHub Desktop.
Setting laptop charging limit in Linux Mint

Setting laptop charging limit in Linux Mint

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 as BAT0
    $ 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 and 80 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

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment