Skip to content

Instantly share code, notes, and snippets.

@ps1dr3x
Last active July 5, 2022 08:46
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 ps1dr3x/747a391a43bf1caf88a3a7ee23d6db4d to your computer and use it in GitHub Desktop.
Save ps1dr3x/747a391a43bf1caf88a3a7ee23d6db4d to your computer and use it in GitHub Desktop.
systemd service to set a charge limit for the laptop's battery (when supported)
[Unit]
Description=Set the battery charge threshold
After=multi-user.target
StartLimitBurst=3
StartLimitIntervalSec=300s
[Service]
Type=oneshot
Restart=on-failure
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment