#!/bin/sh # Blank/restore the display without engaging the passcode locker (U1). # sxmo_wm.sh display off/on already handles brightness, bl_power, DPMS, # the CPU governor and the keyboard backlight. # # 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=/tmp/bananarchy_last_wake GRACE="${BANANARCHY_IDLE_BLANK_GRACE:-10}" 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 exec /usr/bin/sxmo_wm.sh display off ;; on) date +%s > "$WAKE_TS" 2>/dev/null || true exec /usr/bin/sxmo_wm.sh display on ;; *) printf 'Usage: %s [off|on]\n' "${0##*/}" >&2 exit 1 ;; esac