19 lines
817 B
Bash
19 lines
817 B
Bash
#!/bin/sh
|
|||
|
|
# Guarded Sxmo state transition for the 2720 Flip lid daemon.
|
||
|
|
#
|
||
|
|
# The compiled lid daemon already writes the state, the lock flag and the
|
||
|
|
# backlights synchronously; this wrapper only starts the Sxmo hooks. A slow
|
||
|
|
# "screenoff" spawn from a close must not run after the flip has opened and
|
||
|
|
# re-lock or re-blank the phone, so it re-checks the lid state at exec time.
|
||
|
|
set -u
|
||
|
|
|
||
|
|
EXPECTED="${1:-}"
|
||
|
|
ACTION="${2:-}"
|
||
|
|
GENERATION="${3:-}"
|
||
|
|
STATE_FILE="${BANANARCHY_LID_STATE:-/run/bananarchy/lid-state}"
|
||
|
|
GEN_FILE="${BANANARCHY_LID_GENERATION:-/run/bananarchy/lid-generation}"
|
||
|
|
|
||
|
|
[ -n "$EXPECTED" ] && [ -n "$ACTION" ] && [ -n "$GENERATION" ] || exit 0
|
||
|
|
[ "$(cat "$STATE_FILE" 2>/dev/null)" = "$EXPECTED" ] || exit 0
|
||
|
|
[ "$(cat "$GEN_FILE" 2>/dev/null)" = "$GENERATION" ] || exit 0
|
||
|
|
exec /usr/bin/sxmo_state.sh set "$ACTION"
|