You are not logged in.
Pages: 1
Hey everyone,
I am currently having the issue of having to set my battery charge limit manually every time I boot. I am using hyprland and my current solution is a keybind which gives me a popup to input my sudo password (is that the right terminology? sorry if it's not). the command I'm using to set my battery charge limit is this "echo '80' | pkexec tee /sys/class/power_supply/BAT0/charge_control_end_threshold"
I would like to not have to do anything and have it just set the charge limit when I boot.
Does anyone have any better solutions?
Offline
you could create a systemd service that runs at boot that does that
I Have Linux Perl Can i Download Gnome???
Offline
Or use tmpfiles.d(5), which only needs a single line in a file rather than a complete systemd unit.
Jin, Jîyan, Azadî
Offline
I ended up using a systemd service but it doesn't seem to do anything after enabling then rebooting
this is my service
[Unit]
Description=Battery Charge Limit
[Service]
ExecStart=echo '80' | tee /sys/class/power_supply/BAT0/charge_control_end_threshold
[Install]
WantedBy=multi-user.target
what did I do wrong
Offline
Systemd services do not run in a shell, so your pipe doesn't work.
You should probably use tmpfiles.d for this anyway: https://wiki.archlinux.org/title/System … rary_files
Alternatively wrap your ExecStart command in a shell, or write a script with a shebang to run the shell and run that with ExecStart instead.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
And if you do use a unit file with a shell drop the useless use of echo:
ExecStart=/usr/bin/bash -c 'tee /sys/class/power_supply/BAT0/charge_control_end_threshold <<< "80"'https://mywiki.wooledge.org/HereDocument
Or if you prefer
ExecStart=/usr/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'Last edited by Head_on_a_Stick (2025-09-09 06:03:41)
Jin, Jîyan, Azadî
Offline
Pages: 1