Files
bananarchy/overlay/rootfs/usr/bin/bananarchy-lid-gate.sh
T

25 lines
1.0 KiB
Bash
Raw Normal View History

#!/bin/sh
# Closed-flip main-panel gate for the 2720 Flip.
#
# Returns 0 when the main panel / keypad backlight may be lit, 1 when the flip
# is closed. With the "wake" argument a blocked main-panel wake request is
# forwarded to the cover display, so an incoming call, SMS, notification or
# external button can only light the outer panel.
#
# Every wake path (sxmo_wm.sh display on, bananarchy-screen-wake.sh,
# bananarchy-display-power-sync, the input handler) calls this helper, which
# makes /run/bananarchy/lid-state the single source of truth. The compiled lid
# daemon writes that file synchronously before any other transition work.
set -u
PROFILE="${BANANARCHY_LID_PROFILE:-/usr/share/bananarchy/lid-profile}"
STATE="${BANANARCHY_LID_STATE:-/run/bananarchy/lid-state}"
COVERCTL="${BANANARCHY_COVERCTL:-/usr/bin/bananarchy-coverctl}"
[ "$(cat "$PROFILE" 2>/dev/null)" = "flip" ] || exit 0
[ "$(cat "$STATE" 2>/dev/null)" = "closed" ] || exit 0
if [ "${1:-}" = "wake" ] && [ -x "$COVERCTL" ]; then
"$COVERCTL" WAKE >/dev/null 2>&1 || true
fi
exit 1