Set a charge threshold for asus laptop in ubuntu This only works if your computer hardware support it, go to MyASUS app to check this feature
the following command will return your battery name, mine is BAT0 ls /sys/class/power_supply
Before creating the systemd service, check if your laptop actually has charge_control_end_threshold in /sys/class/power_supply/BAT* (without it, this won't work): ls /sys/class/power_supply/BAT*/charge_control_end_threshold continue if it returns the path to charge_control_end_threshold now create a file called battery-charge-threshold.service in /etc/systemd/system by the following command sudo editor /etc/systemd/system/battery-charge-threshold.service in the file, paste the following script
[Unit] Description=Set the battery charge threshold After=multi-user.target StartLimitBurst=0
[Service] Type=oneshot Restart=on-failure ExecStart=/bin/bash -c 'echo CHARGE_STOP_THRESHOLD > /sys/class/power_supply/BATTERY_NAME/charge_control_end_threshold'
[Install] WantedBy=multi-user.target
Here, change BATTERY_NAME with the name of the battery (mine is BAT0), and CHARGE_STOP_THRESHOLD with the battery charge stop threshold you want
Remember that some systems' battery can only be set to some specific value as 60, 80, 100
sudo systemctl enable battery-charge-threshold.service sudo systemctl start battery-charge-threshold.service
edit the /etc/systemd/system/battery-charge-threshold.service file, change the number restart the systemd service using the following commands:
sudo systemctl daemon-reload sudo systemctl restart battery-charge-threshold.service
cat /sys/class/power_supply/BATTERY_NAME/status