Files
mi8-platina-linux/scripts/phone-battery-guard.openrc
T
shenandshen 23989f4a18
Offline project checks / check (push) Canceled after 0s
feat(battery): implement emergency safe shutdown when battery <= 5% discharging
- 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.
2026-11-08 05:32:04 -08:00

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"
}