How to Adjust Gnome Preserve Battery Health thresholds

Thought I might share the below tech note after researching and testing this. Pretty much the default of Gnome starting charging at 75% and stopping at 80% seems too low (so I changed the defaults).

How to Adjust Gnome Preserve Battery Health thresholds

GNOME 48 includes a feature to preserve battery health, which can be enabled in the Power settings under the new Battery Charging option. This feature is designed to enhance the lifespan of the device’s battery by setting charging thresholds. By default, the battery will start charging when its charge drops under 75% of its capacity and will stop charging when it reaches 80%.

To Customise the battery charge thresholds:

  1. Go to Settings> Power > Battery Charging to “Enable Preserve Battery Health” in Gnome.

  2. Confirm the current battery charging threshold by running the command “cat /sys/class/power_supply/BAT0/charge_{start,stop}_threshold”:

❯ cat /sys/class/power_supply/BAT0/charge_{start,stop}_threshold
75
80

The results confirm that charging starts at 75% and stops at 80%.

  1. Create a custom hwdb configuration file (e.g. 61-battery-local.hwdb).
sudo nano /etc/udev/hwdb.d/61-battery-local.hwdb
  1. Add the following content to the 61-battery-local.hwdb configuration file.
battery:*:*:dmi:*  
 CHARGE_LIMIT=75,90

These settings will start charging when the battery drops under 75% and stop charging at 90%.

  1. Load the new rule\configuration, we must run the following command to update the hwdb binary database:
sudo systemd-hwdb update
  1. We also need to use udevadm to trigger kernel events:
sudo udevadm trigger -v
  1. Then restart the upower.service.
sudo systemctl daemon-reload && sudo systemctl restart upower.service
  1. Confirm the new power thresholds have been applied:
❯ cat /sys/class/power_supply/BAT0/charge_{start,stop}_threshold
75
90

Source:
https://linuxconfig.org/using-custom-charge-thresholds-with-gnomes-preserve-battery-health-feature
https://linuxconfig.org/how-to-set-battery-charge-thresholds-on-linux

#gnome #powermanagement

1 Like

Nice! Thanks for sharing!

On my end, this didn’t work:

$ cat /sys/class/power_supply/BAT0/charge_{start,stop}_threshold
cat: /sys/class/power_supply/BAT0/charge_start_threshold: No such file or directory
cat: /sys/class/power_supply/BAT0/charge_stop_threshold: No such file or directory

But this did:

$ cat /sys/class/power_supply/BAT0/charge_control_{start,end}_threshold
75
80

Hey Cactux,

Thanks for sharing your observations.

So I did a little research (as I have a Thinkpad (T450) with 2 batteries in it) and this is what I noticed with it:

  1. For each battery I have a different configuration directory:
  • /sys/class/power_supply/BAT0
  • /sys/class/power_supply/BAT1
  1. When I follow the above procedure it sets both battery thresholds to the same value:
  • /sys/class/power_supply​:locked:
    ❯ cat /sys/class/power_supply/BAT1/charge_{start,stop}_threshold
    75
    90

  • /sys/class/power_supply​:locked:
    ❯ cat /sys/class/power_supply/BAT0/charge_{start,stop}_threshold
    75
    90

I also noticed that if I remove the physical battery, the setting will be removed from the /sys/class/power_supply/ directory.