Skip to content

Instantly share code, notes, and snippets.

@luisnquin
Created April 10, 2022 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisnquin/bc2bd02d8c4c3b0de52e47a9deece3cb to your computer and use it in GitHub Desktop.
Save luisnquin/bc2bd02d8c4c3b0de52e47a9deece3cb to your computer and use it in GitHub Desktop.
Create battery limit on ASUS
[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
  • Name as battery-charge-threshold.service and move to /etc/systemd/system

  • CHARGE_STOP_THRESHOLD -> Battery limit [0-100]

  • BATTERY_NAME -> Obtained from $ ls /sys/class/power_supply. Example: BAT0, BAT1 and BATT.

Then, run:

$ sudo systemctl enable battery-charge-threshold.service
$ sudo systemctl start battery-charge-threshold.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment