From f3c9b3c57a146b3155c27ae9e8e5e934d7ae6d69 Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz Date: Thu, 19 Jun 2025 10:59:04 +0200 Subject: [PATCH] weston-init: wait for a wayland socket before logging in The login prompt appears before Wayland is fully initialized and has created a wayland socket. Logging in too early as root in this scenario caused the WAYLAND_DISPLAY environment variable to be left empty. As a consequence, gstreamer failed to use waylandsink to print contents in the display. Introduce a 10-seconds polling loop to wait for the wayland socket to be available before proceeding with the login. Signed-off-by: Gonzalo Ruiz --- .../wayland/weston-init/weston_profile.sh | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 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 308452ec8..5efd2b5bc 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 @@ -8,11 +8,20 @@ if [ "$USER" == "root" ]; then export PULSE_RUNTIME_PATH=/run/user/`id -u root`/pulse export USE_PLAYBIN3=1 - if [ -e $XDG_RUNTIME_DIR/wayland-0 ]; then - export WAYLAND_DISPLAY=wayland-0 - else - if [ -e $XDG_RUNTIME_DIR/wayland-1 ]; then - export WAYLAND_DISPLAY=wayland-1 - fi + # 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 + sleep 1 + fi + done + + if [ -z "$WAYLAND_DISPLAY" ]; then + echo "WARNING: No Wayland socket found" fi fi