Files
bananarchy/overlay/rootfs/usr/bin/bananarchy-idle-timeout.sh
T
Bantam da68bb8c60 Configurable screen blank (default 5 min), instant lock/lid blank, instant call/SMS wake
- Config -> Screen blank submenu (Off / 30 s / 1 / 5 / 10 / 30 min) backed by
  ~/.config/sxmo/idle_blank_timeout and the new bananarchy-idle-timeout.sh
  get|label|set. Default changed from 60 s to 300 s. dwm reads the file live
  and reloads it on SIGUSR1, so a menu change takes effect without a restart;
  sxmo.noidle and SXMO_UNLOCK_IDLE_TIME still override/disable it.
- Power -> Lock now uses @plugin:locker:screenoff (like Lock (Screen off)), and
  lock_phone_screenoff() resets dwm's idle state, so closing the slider/lid or
  locking blanks the panel immediately instead of waiting for the timeout.
- New bananarchy-screen-wake.sh restores the panel via sxmo_wm.sh display on,
  records /tmp/bananarchy_last_wake and signals dwm (SIGUSR1) to reset
  idle_blanked / last_input_ms. Called from sxmo_hook_ring.sh (incoming call)
  and sxmo_hook_notification.sh (SMS / notifications). dwm also self-heals if
  an external hook turns the panel on without a signal.

Verified live on the connected phone (after deploying the rebuilt dwm/dmenu
and restarting dwm with a rollback backup): idle_locker job is gone, default
reads 300 / 5m, setting 10 s blanks the panel (br 14->0, bl 0->4, DPMS On->Off)
after ~14 s of no input, and bananarchy-screen-wake.sh restores it immediately.
Lock state and 5-minute default were restored afterwards. All scripts pass sh -n.

Rebuilt dwm/dmenu and images/bananarchy-nokia-argon.img with --mkinitfs;
boot.img still contains the known-good zImage + DTB byte-for-byte.
check-rebuild.sh passes and artifact drift is 0.

Docs: MANUAL.md, CHANGELOG.md, AGENTS.md, BATTERY-OPTIMIZATION-ANALYSIS.md (13).
2026-11-07 18:16:26 +02:00

61 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Get or set the unlocked idle screen-blank timeout (seconds).
# Config menu -> "Screen blank" writes ~/.config/sxmo/idle_blank_timeout.
# 0 disables blanking; dwm reloads the file on SIGUSR1.
CFGDIR="${XDG_CONFIG_HOME:-${HOME:-/home/user}/.config}/sxmo"
CFG="$CFGDIR/idle_blank_timeout"
DEFAULT=300
get_secs() {
v="$DEFAULT"
if [ -r "$CFG" ]; then
read -r v < "$CFG" 2>/dev/null || v="$DEFAULT"
fi
case "$v" in ''|*[!0-9]*) v="$DEFAULT" ;; esac
printf '%s\n' "$v"
}
label() {
v="$(get_secs)"
if [ "$v" -le 0 ]; then
printf 'Off\n'
elif [ "$v" -lt 60 ]; then
printf '%ss\n' "$v"
elif [ $((v % 60)) -eq 0 ]; then
printf '%sm\n' "$((v / 60))"
else
printf '%sm%ss\n' "$((v / 60))" "$((v % 60))"
fi
}
notify_dwm() {
p="$(pidof -s dwm 2>/dev/null || true)"
[ -n "$p" ] && kill -USR1 "$p" 2>/dev/null || true
}
case "${1:-get}" in
get)
get_secs
;;
label)
label
;;
set)
v="${2:-}"
case "$v" in ''|*[!0-9]*)
printf 'Usage: %s [get|label|set <seconds>]\n' "${0##*/}" >&2
exit 1
;;
esac
[ "$v" -le 86400 ] || v=86400
mkdir -p "$CFGDIR" 2>/dev/null || true
printf '%s\n' "$v" > "$CFG" || exit 1
notify_dwm
printf '%s\n' "$v"
;;
*)
printf 'Usage: %s [get|label|set <seconds>]\n' "${0##*/}" >&2
exit 1
;;
esac