From 268e2fc55372a6f02567fd2739d0ac8f2f155205 Mon Sep 17 00:00:00 2001 From: Bobby Rong Date: Tue, 5 Nov 2024 12:42:45 +0800 Subject: [PATCH] wayland: Wait for VT switch for LightDM users before starting compositor This specifically workarounds https://github.com/canonical/lightdm/issues/63. --- scripts/xinitrc.in.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/xinitrc.in.in b/scripts/xinitrc.in.in index dae4f2a3..e2ea7984 100755 --- a/scripts/xinitrc.in.in +++ b/scripts/xinitrc.in.in @@ -126,6 +126,23 @@ if test "x$XFCE4_SESSION_WITH_CK" = "x1"; then exit 1 fi else + # workaround https://github.com/canonical/lightdm/issues/63 + if [ -n "$XDG_VTNR" ] && [ -f "/sys/devices/virtual/tty/tty0/active" ]; then + VT_TEST_CNT=1 + while true; do + CURRENT_VT=$(cat /sys/devices/virtual/tty/tty0/active) + if [ "$CURRENT_VT" = "tty$XDG_VTNR" ]; then + break + fi + VT_TEST_CNT=$((VT_TEST_CNT + 1)) + if [ "$VT_TEST_CNT" -gt 100 ]; then + echo "VT $XDG_VTNR is expected but the switch did not happen in the last second, continuing anyway." + break + fi + sleep 0.01 + done + fi + # start xfce4-session normally exec $XFCE4_SESSION_COMPOSITOR xfce4-session fi