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).
This commit is contained in:
Bantam committed 2026-11-07 18:16:26 +02:00
1 parent 22d629f59b
commit da68bb8c60
14 files changed
+226 -12

No files matched your search

+1 -1
View File
@@ -62,7 +62,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7`
- **Documentation**: keep `README.md`, `MANUAL.md`, `SDK.md`, and `CHANGELOG.md` synchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`.
- **Artifact sources**: `prebuilt/` is the single source of truth for compiled artifacts and `scripts/rootfs-packages.txt` for the `armv7` package set. Never edit `overlay/rootfs/` copies of binaries by hand; run `./scripts/sync-prebuilt-overlay.sh` after changing `prebuilt/`.
- **Package hygiene**: keep `scripts/rootfs-packages.txt` free of Rust-based top-level packages (use C `sudo`, never `sudo-rs`) and Wayland-purpose packages; `libwpe` and the `wayland-libs-*` shared libraries stay because GTK3/WebKitGTK link them directly, but no Wayland compositor, backend, or viewer is shipped. `scripts/check-rebuild.sh` enforces this.
- **Power management**: idle blanking is `bananarchy-idle-blank.sh` + `sxmo_hook_unlock.sh`'s `idle_locker` (`SXMO_UNLOCK_IDLE_TIME`, default 60 s; `~/.cache/sxmo/sxmo.noidle` opts out). Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert until a full custom kernel module tree is shipped. Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
- **Power management**: idle blanking is `dwm`'s native evdev timer (`src/sxmo-dwm/dwm.c`) plus `bananarchy-idle-blank.sh`; the timeout lives in `~/.config/sxmo/idle_blank_timeout` (default 300 s, `0` = off), is edited via **Config -> Screen blank** / `bananarchy-idle-timeout.sh`, and is reloaded on `SIGUSR1`. `~/.cache/sxmo/sxmo.noidle` and `SXMO_UNLOCK_IDLE_TIME` still override it. `bananarchy-screen-wake.sh` (called from the ring and notification hooks) wakes the panel for calls/SMS and resets the timer; locking or closing the lid blanks immediately. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert until a full custom kernel module tree is shipped. Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
- **Image residue**: `rebuild-image.sh` strips `/var/cache/apk`, all `apk.log*` files, and unused gettext locale trees before `mke2fs` and aborts the build if any apk cache/log remains; never add an `apk` call after that guard.
- **No on-device compiler**: `scripts/rootfs-packages.txt` ships no `gcc`/`g++`/`musl-dev`/`make` and no Janet runtime (`janet`, `janet-dev`, `jpm`); cross-compile native code with `scripts/build-*.sh`. On-device development uses the Yabasic FFI SDK (`neoui.yab` / `neonet.yab`), which requires `yabasic`, `libffi`, `libneoui.so`, and `libcurl.so.4` — never remove those. `scripts/check-rebuild.sh` guards both sides.
- **Core tools**: `curl`, `bc`, `ed`, `rlwrap`, `mandoc`, `nano`, `less`, and `frotz` are pinned core tools asserted by `scripts/check-rebuild.sh`. Perl, Lua, optional Tcl extensions, and the `sqlite` CLI are excluded, while `tcl`, `python3`, `bash`, `luajit`, `gawk`, `jq`, `gojq`, and `quickjs` remain as hard runtime dependencies.
+12
View File
@@ -417,3 +417,15 @@ userspace changes. Deep standby (U2) stays disabled and inert.
- **DSDS with a PIN-locked SIM**: `provision_slot()` now prefers the ready slot
for `primary-gw-provisioning` when the preferred slot is `pin1`/`puk1`, so the
unlocked SIM registers at boot. `verify-pin` re-runs `boot` after unlock.
---
## 13. Configurable screen blank (post-flash)
U1's idle blanking is now a user-facing setting: **Config -> Screen blank**
(`Off`, 30 s, 1/5/10/30 min; default 5 min) writes
`~/.config/sxmo/idle_blank_timeout`. `dwm` reads it live and reloads on
`SIGUSR1`. Lid close / Power-menu Lock blank immediately; incoming calls and
SMS/notifications wake immediately via `bananarchy-screen-wake.sh`, which also
resets `dwm`'s idle timer. This keeps the panel off for long idle periods
(battery) without delaying call/SMS visibility.
+21
View File
@@ -9,6 +9,27 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased — configurable 5-minute screen blank, instant lock/wake
- **Configurable idle blanking**: added **Config -> Screen blank** (`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 is now **5 minutes**
(was 60 s). `dwm` reads the file live and reloads it on `SIGUSR1`, so a menu
change takes effect without a restart; `sxmo.noidle` / `SXMO_UNLOCK_IDLE_TIME`
still override it.
- **Instant blank on lock/lid**: `Power -> Lock` now uses
`@plugin:locker:screenoff` (like `Lock (Screen off)`), and `lock_phone_screenoff()`
resets `dwm`'s idle state, so closing the slider or locking blanks the panel
immediately instead of waiting for the idle timeout.
- **Instant wake on activity**: 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.
---
## Unreleased — idle-blank wake fix and PIN-locked SIM provisioning
Two issues reported after the recovery image booted:
+1 -1
View File
@@ -101,7 +101,7 @@ sudo dd if=./images/bananarchy-nokia-argon.img of=/dev/sdX bs=4M status=progress
| **Slider close / open** | `SW_LID` (`lid:on` / `lid:off`) | **Close**: close open menu, turn off keypad backlight, and lock phone with passcode (`xlocker`); **Open**: restore screen and keypad backlight and show passcode lock screen |
> **Screen blanking, idle blanking, deep standby, passcode locking (`xlocker`), waking, and brightness persistence**:
> While unlocked, the display now blanks automatically after `SXMO_UNLOCK_IDLE_TIME` seconds of inactivity (60 by default) via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`; any keypad, lid or power key restores it immediately without engaging the passcode locker (the timer resets on the wake key, so it cannot blank again right away). Create `~/.cache/sxmo/sxmo.noidle` to restore the old "unlocked screen never blanks" policy. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Optional **deep standby** is currently **unavailable**: the shipped kernel keeps the pmaports module ABI and has no sleep states in `/sys/power/state`. It stays disabled via `/etc/bananarchy-no-deep-standby`; enabling it requires a full custom kernel module tree (see `BATTERY-OPTIMIZATION-ANALYSIS.md`). Active calls, SSH sessions and VPN/tether connections would block suspension. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake.
> While unlocked (and with the lid open), the display blanks automatically after the configured **Screen blank** timeout — **5 minutes by default** — via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`. Change it in **Config -> Screen blank** (`Off`, 30 s, 1/5/10/30 min), which writes `~/.config/sxmo/idle_blank_timeout`; `bananarchy-idle-timeout.sh get|label|set <seconds>` does the same from the shell, and `SXMO_UNLOCK_IDLE_TIME` or `~/.cache/sxmo/sxmo.noidle` still override/disable it. Closing the slider/lid or locking from the **Power** menu blanks the panel **immediately** (both `Lock` and `Lock (Screen off)` now use `xlocker screenoff`), and an incoming call or SMS/notification turns it back on **immediately** via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer so it cannot blank again right away. Any keypad, lid or power key also restores the display without engaging the passcode locker. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Optional **deep standby** is currently **unavailable**: the shipped kernel keeps the pmaports module ABI and has no sleep states in `/sys/power/state`. It stays disabled via `/etc/bananarchy-no-deep-standby`; enabling it requires a full custom kernel module tree (see `BATTERY-OPTIMIZATION-ANALYSIS.md`). Active calls, SSH sessions and VPN/tether connections would block suspension. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake.
#### 3.1.1 Window tiling modes and switching combos
By default, `dwm` uses the **vertical bottom-stack (`bstack`, `TTT`)** layout so multiple `st` terminals stack **vertically (one under another)** to preserve full line width on the `240x320` portrait screen.
+60
View File
@@ -0,0 +1,60 @@
#!/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
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Wake the screen for an external event (incoming call / SMS / notification)
# and reset dwm's idle-blank timer so it cannot blank again immediately.
export DISPLAY="${DISPLAY:-:0}"
/usr/bin/sxmo_wm.sh display on >/dev/null 2>&1 || true
date +%s > /tmp/bananarchy_last_wake 2>/dev/null || true
p="$(pidof -s dwm 2>/dev/null || true)"
[ -n "$p" ] && kill -USR1 "$p" 2>/dev/null || true
exit 0
Binary file not shown.
Binary file not shown.
@@ -52,6 +52,9 @@ fi
printf '%s\n' "$now_ts" > "$STAMP_FILE"
exec 8>&-
# SMS / notification: turn the panel on immediately and reset the idle timer.
/usr/bin/bananarchy-screen-wake.sh >/dev/null 2>&1 || true
if [ -f "$XDG_CONFIG_HOME/sxmo/ringsettings" ]; then
# shellcheck disable=SC1091
. "$XDG_CONFIG_HOME/sxmo/ringsettings"
@@ -12,6 +12,9 @@
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME:-/home/user}/.config}"
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
# Incoming call: turn the panel on immediately and reset the idle timer.
/usr/bin/bananarchy-screen-wake.sh >/dev/null 2>&1 || true
if [ -z "${SXMO_VIBRATE_DEV:-}" ] && [ ! -e /dev/input/by-path/platform-vibrator-event ]; then
for vdev in /dev/input/by-path/*vibrator*-event; do
if [ -e "$vdev" ]; then
Binary file not shown.
Binary file not shown.
+58 -1
View File
@@ -2428,6 +2428,42 @@ scan_zoneinfo_recursive(const char *base_dir, const char *rel_dir,
closedir(d);
}
/* U1: Config-menu idle-blank timeout helpers. */
static int
read_idle_blank_secs(void)
{
const char *home = getenv("HOME");
char path[256], buf[32];
if (!home || !home[0])
home = "/home/user";
snprintf(path, sizeof(path), "%s/.config/sxmo/idle_blank_timeout", home);
if (!read_first_line(path, buf, sizeof(buf)))
return 300;
char *end = NULL;
long v = strtol(buf, &end, 10);
if (end == buf || v < 0 || v > 86400)
return 300;
return (int)v;
}
static const char *
idle_blank_label(int secs)
{
static char out[32];
if (secs <= 0)
return "Off";
if (secs < 60) {
snprintf(out, sizeof(out), "%d s", secs);
return out;
}
if (secs % 60 == 0) {
snprintf(out, sizeof(out), "%d min", secs / 60);
return out;
}
snprintf(out, sizeof(out), "%d min %d s", secs / 60, secs % 60);
return out;
}
static void
populate_timezone_menu(void)
{
@@ -2890,6 +2926,10 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s Change Timezone", ICON_CLK);
add_menu_item(label, "@menu:timezone", 1);
snprintf(label, sizeof(label), "%s Screen blank: %s", ICON_CLK,
idle_blank_label(read_idle_blank_secs()));
add_menu_item(label, "@menu:idle_blank", 1);
if (!duress) {
int ext_log_on = (access("/tmp/bananarchy_ext_logging", F_OK) == 0 ||
access("/etc/bananarchy/ext_logging", F_OK) == 0);
@@ -2910,11 +2950,28 @@ open_builtin_menu(const char *menu_name, int keep_idx)
add_menu_item(label, "@menu:sys", 1);
snprintf(label, sizeof(label), "%s Close Menu", ICON_CLS);
add_menu_item(label, "@close", 0);
} else if (strcmp(menu_name, "idle_blank") == 0) {
reset_session_defaults(1, "Screen blank");
int cur = read_idle_blank_secs();
static const struct { int secs; const char *name; } opts[] = {
{ 0, "Off" }, { 30, "30 seconds" }, { 60, "1 minute" },
{ 300, "5 minutes" }, { 600, "10 minutes" }, { 1800, "30 minutes" }
};
for (size_t i = 0; i < sizeof(opts) / sizeof(opts[0]); i++) {
snprintf(label, sizeof(label), "%s %s",
opts[i].secs == cur ? ICON_TON : ICON_TOF, opts[i].name);
snprintf(cmd, sizeof(cmd), "bananarchy-idle-timeout.sh set %d", opts[i].secs);
add_menu_item(label, cmd, 1);
}
snprintf(label, sizeof(label), "%s Back to Config", ICON_CFG);
add_menu_item(label, "@menu:config", 1);
snprintf(label, sizeof(label), "%s Close Menu", ICON_CLS);
add_menu_item(label, "@close", 0);
} else if (strcmp(menu_name, "power") == 0) {
reset_session_defaults(1, "Power");
append_active_call_entries();
snprintf(label, sizeof(label), "%s Lock", ICON_LCK);
add_menu_item(label, "@plugin:locker", 0);
add_menu_item(label, "@plugin:locker:screenoff", 0);
snprintf(label, sizeof(label), "%s Lock (Screen off)", ICON_LCK);
add_menu_item(label, "@plugin:locker:screenoff", 0);
snprintf(label, sizeof(label), "%s Logout", ICON_OUT);
+58 -9
View File
@@ -340,10 +340,11 @@ static long long last_wake_ms = 0;
* with evdev input because dwm consumes key events before X sees them,
* which made the screen turn back off immediately after a wake. */
static long long last_input_ms = 0;
static int idle_blank_secs = 60;
static int idle_blank_secs = 300;
static int idle_blank_enabled = 1;
static int idle_blanked = 0;
static int idle_cfg_loaded = 0;
static volatile sig_atomic_t wake_requested = 0;
static int star_down = 0;
static int pound_down = 0;
static long long last_screenshot_ms = 0;
@@ -2465,6 +2466,8 @@ lock_phone_screenoff(void)
int lfd, cfd;
lid_close_pending = 0;
lid_close_deadline_ms = 0;
idle_blanked = 0;
last_input_ms = dwm_now_ms();
softkey_pending = 0;
softkey_first_ms = 0;
softkey_deadline_ms = 0;
@@ -3126,6 +3129,42 @@ restack(Monitor *m)
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
/* U1: read the Config-menu timeout live. 0 / sxmo.noidle disables it. */
static void
read_idle_blank_config(void)
{
const char *env = getenv("SXMO_UNLOCK_IDLE_TIME");
const char *home = getenv("HOME");
char path[256], buf[32] = "";
int secs = 300;
if (!home || !home[0])
home = "/home/user";
snprintf(path, sizeof(path), "%s/.cache/sxmo/sxmo.noidle", home);
idle_blank_enabled = (access(path, F_OK) != 0);
snprintf(path, sizeof(path), "%s/.config/sxmo/idle_blank_timeout", home);
read_sysfs_str(path, buf, sizeof(buf));
if (buf[0] != '\0') {
char *end = NULL;
long v = strtol(buf, &end, 10);
if (end != buf && v >= 0 && v <= 86400) {
secs = (int)v;
if (v == 0)
idle_blank_enabled = 0;
}
} else if (env && atoi(env) > 0) {
secs = atoi(env);
}
idle_blank_secs = secs;
}
static void
idle_wake_signal(int sig)
{
(void)sig;
wake_requested = 1;
}
void
run(void)
{
@@ -3137,19 +3176,29 @@ run(void)
/* main event loop */
XSync(dpy, False);
if (!idle_cfg_loaded) {
const char *env = getenv("SXMO_UNLOCK_IDLE_TIME");
char noidle[256];
struct sigaction sa;
idle_cfg_loaded = 1;
if (env && atoi(env) > 0)
idle_blank_secs = atoi(env);
snprintf(noidle, sizeof(noidle), "%s/.cache/sxmo/sxmo.noidle",
getenv("HOME") ? getenv("HOME") : "/home/user");
if (access(noidle, F_OK) == 0)
idle_blank_enabled = 0;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = idle_wake_signal;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGUSR1, &sa, NULL);
read_idle_blank_config();
last_input_ms = dwm_now_ms();
}
xfd = ConnectionNumber(dpy);
while (running) {
if (wake_requested) {
wake_requested = 0;
read_idle_blank_config();
last_input_ms = dwm_now_ms();
idle_blanked = 0;
}
if (idle_blanked && !is_screen_off()) {
/* A call/SMS hook turned the panel back on externally. */
idle_blanked = 0;
last_input_ms = dwm_now_ms();
}
while (XPending(dpy)) {
if (XNextEvent(dpy, &ev))
return;