Linux: Setting Up Adaptive Battery Charging on Ubuntu

🔺 For cellphones 🔺

💻️ Welcome and thank you for visiting. Having an issue with your Windows 10 or 11 computer? Use the search tool 🔍️ above and you can find the answers to your issue. All searches remain in house. Enjoy your stay and always RTFM.

To set up adaptive battery charging on Ubuntu, you can check if your laptop supports charge thresholds by running specific commands in the terminal. If supported, you can manually configure the battery charge limits using commands to set the start and end charging thresholds, or you can wait for future updates in GNOME that may provide a graphical interface for this feature.

Setting Up Adaptive Battery Charging on Ubuntu

Adaptive battery charging helps prolong the lifespan of your laptop’s battery by limiting the maximum charge level. Here’s how to set it up on Ubuntu.

Check Laptop Compatibility

  1. Open Terminal: Press Ctrl + Alt + T.
  2. List Power Supply: Run the command:
ls /sys/class/power_supply/
  1. Look for your battery, usually named BAT0, BAT1, etc.
  2. Check Support: Run:
ls /sys/class/power_supply/BAT0
  1. Replace BAT0 with your battery name. Look for files named charge_control_start_threshold and charge_control_end_threshold. If they exist, your laptop supports charge limiting.

Set Charge Limits

  1. Set Start Charging Level: To limit charging to 80%, run:
sudo sh -c "echo 80 > /sys/class/power_supply/BAT0/charge_control_start_threshold"

Set Maximum Charge Level: To stop charging at 90%, run:

sudo sh -c "echo 90 > /sys/class/power_supply/BAT0/charge_control_end_threshold"

Make Changes Permanent

To ensure these settings persist after reboot:

  1. Create a Systemd Service: Open terminal and run:
sudo nano /etc/systemd/system/battery-charge.service

Add the Following Lines:

[Unit]
Description=Set Battery Charge Maximum Limit
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 90 > /sys/class/power_supply/BAT0/charge_control_end_threshold'

[Install]
WantedBy=multi-user.target

Enable the Service:

sudo systemctl enable battery-charge.service

Conclusion

After following these steps, your Ubuntu laptop will limit battery charging, helping to maintain battery health over time.