Replace idle network poller with event-driven dispatcher

A/B measure and reject additional VM/sysctl/mount tweaks that did not improve idle without trade-offs. Remove sxmo_networkmonitor's long-lived nmcli device monitor, replace it with NetworkManager dispatcher hooks that run Sxmo network/statusbar hooks as the X session user, disable the superd unit in both start hooks, guard it in check-rebuild.sh, update docs, rebuild the image, and verify live Wi-Fi reconnect and idle context switches.
This commit is contained in:
Luxferre committed 2026-11-08 09:28:13 +02:00
1 parent 3543556735
commit 608a8ac71b
11 files changed
+236 -7

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#!/bin/sh
# NetworkManager dispatcher helper: run Sxmo network hooks as the X session
# user. The dispatcher runs as root; keeping status files user-owned avoids
# breaking sxmo_status.sh, dmenu and the status bar after a network event.
set -u
DEVICE="${1:-}"
ACTION="${2:-}"
[ -n "$DEVICE" ] && [ -n "$ACTION" ] || exit 0
export HOME=/home/user
export USER=user
export LOGNAME=user
export SHELL=/bin/ash
export XDG_RUNTIME_DIR=/run/user/10000
export XDG_CONFIG_HOME=/home/user/.config
export XDG_CACHE_HOME=/home/user/.cache
export XDG_DATA_HOME=/home/user/.local/share
export XDG_STATE_HOME=/home/user/.local/state
export SXMO_WM=dwm
export SXMO_STATE=/run/user/10000/sxmo.state
export SXMO_STATUS_NAME=default
export DISPLAY=:0
export PATH="/home/user/.local/bin:/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin"
TYPE="$(nmcli -g GENERAL.TYPE device show "$DEVICE" 2>/dev/null || true)"
[ -n "$TYPE" ] || TYPE=unknown
case "$ACTION" in
up|vpn-up)
sxmo_hook_network_up.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
;;
down|vpn-down)
sxmo_hook_network_down.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
;;
pre-up|vpn-pre-up)
sxmo_hook_network_pre_up.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
;;
pre-down|vpn-pre-down)
sxmo_hook_network_pre_down.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
;;
connectivity-change|dhcp4-change|dhcp6-change|dns-change)
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
;;
*) exit 0 ;;
esac
exit 0
@@ -121,8 +121,11 @@ if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi
# It watch network changes and update the status bar icon by example
superctl start sxmo_networkmonitor
# Network state changes are handled by the NetworkManager dispatcher
# (30-bananarchy-network-status.sh + bananarchy-network-event.sh), so no
# long-lived "nmcli device monitor" poller is started at idle. Disable the
# superd unit too, in case an older session enabled it.
superctl disable sxmo_networkmonitor >/dev/null 2>&1 || true
# The daemon that display notifications popup messages
superctl start sxmo_notificationmonitor