From d9e2154ddcb135cb7754bad9251bbb4afb228ad6 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Tue, 19 May 2026 17:34:12 +0200 Subject: [PATCH] weston-init: skip socket wait without a display The previous socket wait fixed a race where the login prompt could appear before Weston had created its Wayland socket. In that case, logging in as root left WAYLAND_DISPLAY empty and applications could not use waylandsink. Only wait for the socket when a DRM display is connected, or when the kernel does not expose DRM connector status files. This keeps the race fix for display boots while allowing immediate headless logins. Keep showing a warning when there is no wayland socket. https://onedigi.atlassian.net/browse/DEL-10141 Signed-off-by: Isaac Hermida --- .../wayland/weston-init/weston_profile.sh | 60 ++++++++++++++----- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-graphics/wayland/weston-init/weston_profile.sh b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-graphics/wayland/weston-init/weston_profile.sh index 5efd2b5bc..0a8e56f34 100644 --- a/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-graphics/wayland/weston-init/weston_profile.sh +++ b/meta-digi-arm/dynamic-layers/stm-st-stm32mp/recipes-graphics/wayland/weston-init/weston_profile.sh @@ -1,4 +1,38 @@ -if [ "$USER" == "root" ]; then +find_wayland_display() +{ + if [ -e "$XDG_RUNTIME_DIR/wayland-0" ]; then + export WAYLAND_DISPLAY=wayland-0 + return 0 + fi + + if [ -e "$XDG_RUNTIME_DIR/wayland-1" ]; then + export WAYLAND_DISPLAY=wayland-1 + return 0 + fi + + return 1 +} + +has_connected_drm_display() +{ + local drm_status + local drm_status_found=false + local drm_state + + for drm_status in /sys/class/drm/card*-*/status; do + [ -e "$drm_status" ] || continue + + drm_status_found=true + read -r drm_state < "$drm_status" || continue + if [ "$drm_state" = "connected" ]; then + return 0 + fi + done + + [ "$drm_status_found" = "false" ] +} + +if [ "$USER" = "root" ]; then export XDG_RUNTIME_DIR=/run/user/`id -u root` export ELM_ENGINE=wayland_shm @@ -8,20 +42,16 @@ if [ "$USER" == "root" ]; then export PULSE_RUNTIME_PATH=/run/user/`id -u root`/pulse export USE_PLAYBIN3=1 - # Wait for 10 seconds until a Wayland socket is available - for i in {1..10}; do - if [ -e $XDG_RUNTIME_DIR/wayland-0 ]; then - export WAYLAND_DISPLAY=wayland-0 - break - elif [ -e $XDG_RUNTIME_DIR/wayland-1 ]; then - export WAYLAND_DISPLAY=wayland-1 - break - else + if ! find_wayland_display && has_connected_drm_display; then + # Weston may still be creating its socket after the login prompt + # appears, but do not delay headless serial logins. + for i in {1..10}; do sleep 1 - fi - done - - if [ -z "$WAYLAND_DISPLAY" ]; then - echo "WARNING: No Wayland socket found" + find_wayland_display && break + done fi + [ -z "$WAYLAND_DISPLAY" ] && echo "WARNING: No Wayland socket found" fi + +unset -f find_wayland_display +unset -f has_connected_drm_display