18 lines
699 B
Bash
18 lines
699 B
Bash
#!/bin/sh
|
|||
|
|
# Root helper: enter the deepest *safe* system sleep state.
|
||
|
|
# Called via doas from bananarchy-deep-standby.sh.
|
||
|
|
STATE_FILE=/sys/power/state
|
||
|
|
[ -r "$STATE_FILE" ] || exit 0
|
||
|
|
states=""
|
||
|
|
read -r states < "$STATE_FILE" 2>/dev/null || states=""
|
||
|
|
target=""
|
||
|
|
# freeze (s2idle) keeps every IRQ wake-capable, so keypad, lid, modem and
|
||
|
|
# Wi-Fi always resume the phone. mem needs platform wakeup sources and is
|
||
|
|
# therefore opt-in.
|
||
|
|
case " $states " in *" freeze "*) target=freeze ;; esac
|
||
|
|
if [ -f /etc/bananarchy-allow-mem-suspend ]; then
|
||
|
|
case " $states " in *" mem "*) target=mem ;; esac
|
||
|
|
fi
|
||
|
|
[ -n "$target" ] || exit 0
|
||
|
|
# This write blocks until the system resumes.
|
||
|
|
printf '%s\n' "$target" > "$STATE_FILE"
|