diff options
author | Daniel Levin <daniel.levin@amd.com> | 2023-08-08 20:31:56 -0600 |
---|---|---|
committer | Mark Hatle <mark.hatle@amd.com> | 2023-08-14 10:16:29 -0500 |
commit | 9220f00412b1cce5c3904ffda19c4ad87d8e83e4 (patch) | |
tree | 563778e410a5bb64b9e2b680ff08b959fc7ef28f /meta-xilinx-core/recipes-graphics/xorg-xserver | |
parent | ef56d304f5fcf24020c3cd4cd62ce2d16247abb6 (diff) | |
download | meta-xilinx-9220f00412b1cce5c3904ffda19c4ad87d8e83e4.tar.gz |
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 <daniel.levin@amd.com>
Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-core/recipes-graphics/xorg-xserver')
-rwxr-xr-x | meta-xilinx-core/recipes-graphics/xorg-xserver/xserver-xorg/monitor-hotplug.sh | 19 |
1 files 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) | |||
27 | 27 | ||
28 | # inspired by /etc/acpd/lid.sh and the function it sources. | 28 | # inspired by /etc/acpd/lid.sh and the function it sources. |
29 | 29 | ||
30 | displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X##` | 30 | # Read first X display number from the list. |
31 | displaynum=`ls /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X## | head -n 1` | ||
32 | displaynum=${displaynum%% *} | ||
33 | |||
31 | display=":$displaynum.0" | 34 | display=":$displaynum.0" |
32 | export DISPLAY=":$displaynum.0" | 35 | export DISPLAY=":$displaynum.0" |
33 | 36 | ||
34 | # from https://wiki.archlinux.org/index.php/Acpid#Laptop_Monitor_Power_Off | 37 | # from https://wiki.archlinux.org/index.php/Acpid#Laptop_Monitor_Power_Off |
35 | export XAUTHORITY=$(ps -C Xorg -f --no-header | sed -n 's/.*-auth //; s/ -[^ ].*//; p') | 38 | |
39 | # Clear XAUTHORITY by default in case X session is not using display manager. | ||
40 | unset XAUTHORITY | ||
41 | |||
42 | # Detect X session command line started for the display $displaynum and extract | ||
43 | # -auth argument if any. | ||
44 | ps -eo args | grep -e "Xorg\W*:$displaynum" | grep -e -auth | while read -r line | ||
45 | do | ||
46 | if [[ "${line%% *}" == *Xorg ]]; then | ||
47 | export XAUTHORITY=`echo $line | sed -n 's/.*-auth //; s/ -[^ ].*//; p'` | ||
48 | break | ||
49 | fi | ||
50 | done | ||
36 | 51 | ||
37 | for i in /sys/class/drm/*/*/status ; | 52 | for i in /sys/class/drm/*/*/status ; |
38 | do | 53 | do |