#!/bin/sh # Blank/restore the display and arm the screenlock daemon (U1). # sxmo_wm.sh display off/on handles brightness, bl_power, DPMS, the CPU # governor and the keyboard backlight. bananarchy-idle-lock.sh then arms the # trusted screenoff transition that starts xlocker screenoff (LOCK_BLANK on # locker.so); without it the resident locker daemon never sees a blank event. # # A wake-grace guard makes this safe even on the legacy sxmo_idle.sh path: # xprintidle can report a stale large idle value right after a wake, which # used to fire the blank command again immediately. WAKE_TS="${BANANARCHY_WAKE_TS:-/tmp/bananarchy_last_wake}" GRACE="${BANANARCHY_IDLE_BLANK_GRACE:-10}" LOCK_HELPER="${BANANARCHY_IDLE_LOCK_HELPER:-/usr/bin/bananarchy-idle-lock.sh}" WM_CMD="${BANANARCHY_WM_CMD:-/usr/bin/sxmo_wm.sh}" case "${1:-}" in off) now=$(date +%s) last=0 [ -r "$WAKE_TS" ] && { read -r last < "$WAKE_TS" 2>/dev/null || last=0; } case "$last" in ''|*[!0-9]*) last=0 ;; esac if [ $((now - last)) -lt "$GRACE" ]; then exit 0 fi "$WM_CMD" display off >/dev/null 2>&1 || true "$LOCK_HELPER" arm >/dev/null 2>&1 || true exit 0 ;; on) "$LOCK_HELPER" cancel >/dev/null 2>&1 || true date +%s > "$WAKE_TS" 2>/dev/null || true exec "$WM_CMD" display on ;; cancel) # Called by the wake paths before they power the panel back on. "$LOCK_HELPER" cancel >/dev/null 2>&1 || true exit 0 ;; *) printf 'Usage: %s [off|on|cancel]\n' "${0##*/}" >&2 exit 1 ;; esac