Endeavous OS - laptop charge limit

To check if you are able to use charge limits, you can try to run the following command in konsole:

echo 85 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

If you do not get a bunch of errors or some access denied error, then this might be working for you. Check by charging the laptop untill you reach (in this case) 85%. The laptop should then stop charging and remind you that you have set up a limit. Excellent.

It could be that your battery is called something else than BAT0, if so, you might have to change the commands below to reflect that. To check your battery name you could run

ls /sys/class/power_supply/

And if you wander which features are available in your battery, you can check that out too:

ls /sys/class/power_supply/BAT0

However, this is not persisted. A reboot will remove this limit. So to persist this change we can create a service that will make sure that this is enforced. It in fact not too difficult (although I did have to look this up).

Create new service

We need to create a service. To do so:

sudo nano /etc/systemd/system/battery-charge-limit.service

Add the following to the file that you just created:

[Unit]
Description=Set battery charge limit to 80%
After=multi-user.target
StartLimitBurst=0

[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

To exit, you can use CTRL+X and it will ask you to save, which I encourage you to do.

Activate and start service

We need to make sure the service is run at startup and that it actually starts. Do that by running the following:

sudo systemctl daemon-reload
sudo systemctl enable battery-charge-limit.service
sudo systemctl start battery-charge-limit.service

Once that is done, you can verify that the service actually is running:

sudo systemctl status battery-charge-limit.service

You should see something like this:

○ battery-charge-limit.service - Set battery charge limit to 85%
    Loaded: loaded (/etc/systemd/system/battery-charge-limit.service; enabled; preset: disabled)
    Active: inactive (dead) since Sun 2025-10-19 10:38:04 CEST; 9min ago
Invocation: e0f8269e5dc642f8b8bff951877e8e51
   Process: 1551 ExecStart=/bin/bash -c echo 85 > /sys/class/power_supply/BAT0/charge_control_end_threshold (code=exited, st>
  Main PID: 1551 (code=exited, status=0/SUCCESS)
  Mem peak: 1.7M
       CPU: 6ms

oct. 19 10:38:03 laptopname systemd[1]: Starting Set battery charge limit to 85%...
oct. 19 10:38:04 laptopname systemd[1]: battery-charge-limit.service: Deactivated successfully.
oct. 19 10:38:04 laptopname systemd[1]: Finished Set battery charge limit to 85%.

The limit is now set. Your laptop will not charge more than your set limit.

Remove service

Should you ever want to remove the charging limit and the service, you can just run the following:

sudo systemctl stop battery-charge-limit.service
sudo systemctl disable battery-charge-limit.service
sudo rm /etc/systemd/system/battery-charge-limit.service
sudo systemctl daemon-reload
sudo systemctl reset-failed

You can check that the service is removed

sudo systemctl status battery-charge-limit.service

You should see an error indicating that the service does not exists.

A lot of my information is derived from https://ubuntuhandbook.org/index.php/2024/02/limit-battery-charge-ubuntu/. Thanks!