scripts: default keepawake to allow display sleep

This commit is contained in:
Ruslan Belkin 2026-03-02 17:55:51 -08:00
parent d413684f03
commit 1580fe1018
2 changed files with 12 additions and 3 deletions

View File

@ -231,7 +231,8 @@ scripts/openclaw-keepawake.sh off
Details:
- Uses `caffeinate -dimsu` in the background.
- Uses `caffeinate -imsu` in the background (allows display sleep).
- Set `OPENCLAW_KEEPAWAKE_FLAGS=-dimsu` if you want displays to stay on.
- Stores PID at `~/.openclaw/run/keepawake.pid`.
- Requires macOS (`caffeinate` command).

View File

@ -2,6 +2,7 @@
set -euo pipefail
PID_FILE="${OPENCLAW_KEEPAWAKE_PID_FILE:-$HOME/.openclaw/run/keepawake.pid}"
KEEPAWAKE_FLAGS="${OPENCLAW_KEEPAWAKE_FLAGS:--imsu}"
usage() {
cat <<'USAGE'
@ -14,6 +15,10 @@ Commands:
off Stop keep-awake background process
status Show current keep-awake status
restart Restart keep-awake background process
Environment:
OPENCLAW_KEEPAWAKE_FLAGS caffeinate flags (default: -imsu)
Use -dimsu to keep displays awake too.
USAGE
}
@ -50,10 +55,13 @@ start_awake() {
return 0
fi
caffeinate -dimsu >/dev/null 2>&1 &
local -a flags
# Allow override for special cases (for example keeping displays on).
read -r -a flags <<<"$KEEPAWAKE_FLAGS"
caffeinate "${flags[@]}" >/dev/null 2>&1 &
pid="$!"
echo "$pid" >"$PID_FILE"
echo "keep-awake on (pid $pid)"
echo "keep-awake on (pid $pid, flags: $KEEPAWAKE_FLAGS)"
}
stop_awake() {