How to start battery-charge-threshold.service on boot

Following this guide, I have successfully set my battery-charge-threshold.service. The issue is that I have to do the following after each boot for it to take effect:

sudo systemctl daemon-reload
sudo systemctl restart battery-charge-threshold.service

Is there a way to force this on boot? I think it was working fine with my previous EOS installation. I’m not sure what I’ve changed that disables the service after I shut down the machine. Thank you.

Wouldn’t

sudo systemctl enable --now battery-charge-threshold.service

make it to start after reboot? Try the command above and check the status of the service:

systemctl status battery-charge-threshold.service

Reboot and see if it gets started at boot.

2 Likes

Also worth reading: https://wiki.archlinux.org/title/Systemd#Basic_systemctl_usage

2 Likes

For some reason it got deactivated after reboot.


(base) [tigran@asus ~]$ systemctl status battery-charge-threshold.service
○ battery-charge-threshold.service - Set the battery charge threshold
     Loaded: loaded (/etc/systemd/system/battery-charge-threshold.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Tue 2021-11-23 12:46:58 CST; 4min 33s ago
    Process: 568 ExecStart=/bin/bash -c echo 25 > /sys/class/power_supply/BAT0/charge_control_end_threshold (code=exited, status=0/SUCCESS)
   Main PID: 568 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Nov 23 12:46:58 asus systemd[1]: Starting Set the battery charge threshold...
Nov 23 12:46:58 asus systemd[1]: battery-charge-threshold.service: Deactivated successfully.
Nov 23 12:46:58 asus systemd[1]: Finished Set the battery charge threshold.

Connected to AC, what do

cat /sys/class/power_supply/BAT0/charge_control_end_threshold

and

cat /sys/class/power_supply/BATTERY_NAME/status

say?

100

Charging

After running

sudo systemctl restart battery-charge-threshold.service

It works again.

cat /sys/class/power_supply/BAT0/status
Discharging
cat /sys/class/power_supply/BAT0/charge_control_end_threshold
25

Is there a place where I should add:
sudo systemctl start battery-charge-threshold.service so that it will start at boot?

Not really. Normally when you enable a service it should get started at boot. I have no idea why it doesn’t in this case.

Does
systemctl --failed
show anything after you boot?

is this not exactly what it should do?
Starting Set the battery charge threshold will
ExecStart=/bin/bash -c echo 25 > /sys/class/power_supply/BAT0/charge_control_end_threshold

after set this it goes to sleep till next reboot…
status says all is fine too
Loaded: loaded (/etc/systemd/system/battery-charge-threshold.service; enabled

1 Like
systemctl --failed
  UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.

In this case why do I get

cat /sys/class/power_supply/BAT0/charge_control_end_threshold
100

And why does it work only after

sudo systemctl start battery-charge-threshold.service

?

Oh I have noticed similar behavior with my /proc/cmdline. Every time I update it following this guide, it goes back to its initial state after reboot. The content does not hold after the next boot

It seems like somehow my system file contents go back to their default states after I shut down.

that’s what i wanted to mention something else is setting it back after the service done his job :wink:
Could be TLP doing this.

I don’t have tlp. I have installed my nvidia following this guide. So I installed asusctl supergfxctl and one of those had conflict with tlp so pacman removed tlp. I didn’t understand much about what happened tho. But since everything seemed fine, I moved on. How can I understand exactly which package does that?

Ugh, this article says:

When installing EndeavourOS don’t use the option with Nvidia drivers preinstalled, this installs configs with might conflict with supergfxctl and installs the driver with works only with stock kernel. Use the default install option then install nvidia-dkms post install.

Nvidia is such a %$^