Protect Lenovo laptop battery

In order to protect your Lenovo battery, you can set charge start and end thresholds. According to anecdotal evidence, good values are 40% to 50%.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cat <<'EOF' > /etc/systemd/system/battery-max.service
[Unit]
Description=Set the battery charge threshold
After=multi-user.target

StartLimitBurst=0
[Service]
Type=oneshot
Restart=on-failure

ExecStart=/bin/bash -c 'echo 50 > /sys/class/power_supply/BAT0/charge_control_end_threshold; echo 40 > /sys/class/power_supply/BAT0/charge_start_threshold'
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now battery-max.service