← Back to team overview

ubuntu-x-swat team mailing list archive

[Bug 660901] Re: udev scripts running as root cannot use xrandr

 

Hi Alex,

the problem is, also root hasn't the rights to use a x-server owned by
an other user. You can force root to use an other users xauthority by
setting the environment variable to the users xauthority data:

export XAUTHORITY=/home/.../.Xauthority

Here is my hack to use the external monitor if the VGA is plugged in:

/etc/udev/rules.d/70-external-monitor.rules:
# VGA changed
KERNEL=="card0", ACTION=="change", RUN+="/usr/local/scripts/external-monitor.sh"

/usr/local/scripts/external-monitor.sh:
#!/bin/sh

status="$(cat /sys/class/drm/card0-VGA-1/status)"

export XAUTHORITY=/home/marius/.Xauthority 
export DISPLAY=:0.0

if [ "${status}" = disconnected ] 
then
	xrandr --output LVDS1 --auto --output VGA1 --off
elif [ "${status}" = connected ] 
then
	xrandr --output LVDS1 --off --output VGA1 --auto
fi

-- 
udev scripts running as root cannot use xrandr
https://bugs.launchpad.net/bugs/660901
You received this bug notification because you are a member of Ubuntu-X,
which is subscribed to xserver-xorg-video-intel in ubuntu.



References