I have setup a oneshot service to set my laptop's battery charge threshold.
Here is the execline script I wrote.
#!/usr/bin/execlineb -P
pipeline { printf "60" }
tee /sys/class/power_supply/BAT1/charge_control_end_threshold
I've also made sure to add mount-sysfs as a dependency, so it executes after /sys/ has been mounted.
For some reason my script still does not wok.
So I modified it a little bit to see where it went wrong
#!/usr/bin/execlineb -P
foreground { touch /tmp/executed_before }
backtick -E output {
pipeline { printf "60" }
foreground { tee /sys/class/power_supply/BAT1/charge_control_end_threshold }
cat /sys/class/power_supply/BAT1/charge_control_end_threshold
}
touch /tmp/executed_after${output}
Running it manually shows:
[userman@admin ~]$ doas s6-rc -u change battery-limit
[userman@admin ~]$ ls /tmp/
dbus-BTKoOSfitJ dbus-QHIFxt8UXP executed_after6060 executed_before
[userman@admin ~]$ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
60
[userman@admin ~]$
But when it executes on boot, it shows:
[userman@admin ~]$ ls /tmp/
dbus-BTKoOSfitJ executed_before
[userman@admin ~]$ cat /sys/class/power_supply/BAT1/charge_control_end_threshold
100
So I have 2 questions:
- What is happening here?
- Is there a way to check the output/exit code of a oneshot service without having to modify it?