How to Limit Battery Charging (Set a Charge Threshold) for ASUS Laptops on Linux

by: linuxuprising.com

Steps:

Check your battery name:

Command
ls /sys/class/power_supply
Output
furan@laptop:~$ ls /sys/class/power_supply
AC0  BAT0

Create a systemd service:

Command
sudo nano /etc/systemd/system/battery-charge-threshold.service
File Content
[Unit]
Description=Set the battery charge threshold
After=multi-user.target
StartLimitBurst=0

[Service]
Type=oneshot
Restart=on-failure
ExecStart=/bin/bash -c 'echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
# Note: "60" is the maximum battery charging limit (percentage). Change it as you like.

[Install]
WantedBy=multi-user.target

Enable and start the service:

Commands
sudo systemctl daemon-reload
sudo systemctl enable battery-charge-threshold.service
sudo systemctl start battery-charge-threshold.service

Check if it's working:

Command
cat /sys/class/power_supply/BAT0/status

Disclaimer: Always check the original source. This works for me, but it may not work for you.