by limiting its charge to 90%
If you, like me, use KDE, then in System Settings -> Power Management -> Advanced Power Settings you might've noticed an option to stop charging your battery when it reaches some percentage (and also to start charging only once below some other percentage). Personally, I've set one of them to 90%, and another one - to 80%.
However, you might've noticed that this setting, while working nicely, seems to be not preserved over reboots. There is a closed discussion on Manjaro forums and an article on ArchWiki about it.
From there, you might find a workaround: just make a systemd service to set these settings for you after reboot!
-
Create a file
/etc/systemd/system/battery-charge-threshold.service
with content like this:[Unit] Description=Set the battery charge threshold After=multi-user.target StartLimitBurst=0 [Service] Type=oneshot Restart=on-failure ExecStart=/bin/bash -c 'echo 90 > /sys/class/power_supply/BAT0/charge_control_end_threshold && echo 80 > /sys/class/power_supply/BAT0/charge_control_start_threshold' [Install] WantedBy=multi-user.target
-
Run the following commands to enable it:
sudo chmod 644 /etc/systemd/system/battery-charge-threshold.service sudo systemctl daemon-reload sudo systemctl enable battery-charge-threshold.service
-
Enjoy extended life of your laptop battery... maybe... for the price of shorter "laptop life from one charge", hehe