From 9220f00412b1cce5c3904ffda19c4ad87d8e83e4 Mon Sep 17 00:00:00 2001 From: Daniel Levin Date: Tue, 8 Aug 2023 20:31:56 -0600 Subject: monitor-hotplug.sh: Fix detecting XAUTHORITY Previously XAUTHORITY location was detected by filtering Xorg process command line, which is not available in busybox ps implementation. Instead detect correct Xorg commnad line by grepping for the "Xorg :displaynum" and extract -auth argument. If no -auth argument present then Xorg is running without display manager, thus XAUTHORITY env var should remain undefined. Signed-off-by: Daniel Levin Signed-off-by: Sandeep Gundlupet Raju Signed-off-by: Mark Hatle --- .../xorg-xserver/xserver-xorg/monitor-hotplug.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh index d603082d..bceb5607 100755 --- a/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh +++ b/meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh @@ -27,12 +27,27 @@ DEVICES=$(find /sys/class/drm/*/status) # inspired by /etc/acpd/lid.sh and the function it sources. -displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X##` +# Read first X display number from the list. +displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X## | head -n 1` +displaynum=${displaynum%% *} + display=":$displaynum.0" export DISPLAY=":$displaynum.0" # from https://wiki.archlinux.org/index.php/Acpid#Laptop_Monitor_Power_Off -export XAUTHORITY=$(ps -C Xorg -f --no-header | sed -n 's/.*-auth //; s/ -[^ ].*//; p') + +# Clear XAUTHORITY by default in case X session is not using display manager. +unset XAUTHORITY + +# Detect X session command line started for the display $displaynum and extract +# -auth argument if any. +ps -eo args | grep -e "Xorg\W*:$displaynum" | grep -e -auth | while read -r line +do + if [[ "${line%% *}" == *Xorg ]]; then + export XAUTHORITY=`echo $line | sed -n 's/.*-auth //; s/ -[^ ].*//; p'` + break + fi +done for i in /sys/class/drm/*/*/status ; do -- cgit v1.2.3-54-g00ecf