Offline project checks / check (push) Canceled after 0s
- Add should_shutdown() check in BatteryPolicy and trigger_shutdown() in phone-battery-guard.py. - Auto sync filesystems and invoke safe poweroff if SoC drops to 5% while on battery/discharging. - Do not power off if external charger is actively connected and charging. - Update openrc service command args with --shutdown-at 5. - Add unit tests for emergency shutdown, discharging detection, and threshold validation.
19 lines
630 B
Plaintext
Executable File
19 lines
630 B
Plaintext
Executable File
#!/sbin/openrc-run
|
|
description="Platina battery health and emergency shutdown daemon (50-65% SoC, auto-poweroff <= 5%)"
|
|
command="/usr/local/sbin/platina-battery-guard"
|
|
command_user="root:root"
|
|
command_args="--low ${low:-50} --high ${high:-65} --max-temp ${max_temp:-45} --shutdown-at ${shutdown_at:-5} --interval ${interval:-60}"
|
|
command_background="yes"
|
|
pidfile="/run/platina-battery-guard.pid"
|
|
output_log="/var/log/platina-battery-guard.log"
|
|
error_log="/var/log/platina-battery-guard.log"
|
|
|
|
depend() {
|
|
need localmount
|
|
after udev-trigger
|
|
}
|
|
|
|
start_pre() {
|
|
checkpath --file --mode 0640 --owner root:root "$output_log"
|
|
}
|