From bbd239bfd0b6b0e9626bfddc2b52ea1df46405c0 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Wed, 22 Apr 2026 14:55:53 -0300 Subject: [PATCH] fix(server): persist stable HDMI connector names --- scripts/install/server.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/install/server.sh b/scripts/install/server.sh index cd23bd7..7436ab1 100755 --- a/scripts/install/server.sh +++ b/scripts/install/server.sh @@ -31,20 +31,26 @@ is_attached_state() { } detect_connected_hdmi_connector() { - local dev name status score suffix + local dev name stable_name status score suffix local best="" best_score=0 best_suffix=0 declare -A scores=() # HDMI status can briefly flap during gadget/display bring-up. Sample a few # times and prefer the connector that stays connected; ties prefer HDMI-A-2, # which is the dedicated downstream capture leg on the current Pi layout. + # Store the logical connector suffix, not the DRM card prefix, so this stays + # valid if Linux renumbers cardN across boots. for _ in 1 2 3 4 5; do for dev in /sys/class/drm/card*-HDMI-A-*; do [[ -e $dev/status ]] || continue name=$(basename "$dev") + stable_name=$name + if [[ $name =~ (HDMI-A-[0-9]+)$ ]]; then + stable_name=${BASH_REMATCH[1]} + fi status=$(cat "$dev/status" 2>/dev/null || true) if [[ $status == connected ]]; then - scores[$name]=$(( ${scores[$name]:-0} + 1 )) + scores[$stable_name]=$(( ${scores[$stable_name]:-0} + 1 )) fi done sleep 0.2