udev scripts running as root cannot use xrandr

Bug #660901 reported by webmeischda
This bug affects 2 people
Affects Status Importance Assigned to Milestone
xserver-xorg-video-intel (Ubuntu)

Bug Description

Binary package hint: xorg

I use a small script called by udev (as root user) whenever I place my laptop on the docking station or remove it again. This script uses xrandr to turn off the laptop display and switch on my primary monitor (or vice versa):
DISPLAY=:0.0 xrandr --output HDMI1 --auto
DISPLAY=:0.0 xrandr --output LVDS1 --off

It used to work fine in lucid, but in maverick both commands fail:
No protocol specified
Can't open display :0.0

I've discovered two possible workarounds:
- add XAUTHORITY=/var/run/gdm/auth-for-[...]/database to the commands
- call xhost +si:localuser:root on login (as default user)

At the moment, I use the second workaround as it is easier to implement. I can't see any reason why root should have no access, after all root has the power to take the required rights at any time. Therefore, I suggest to give root access by default, so scripts like these run without problems and this regression in comparison to lucid is fixed.

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: xorg 1:7.5+6ubuntu3
ProcVersionSignature: Ubuntu 2.6.35-22.34-generic
Uname: Linux 2.6.35-22-generic x86_64
Architecture: amd64
 status: disconnected
 enabled: disabled
 dpms: Off
 status: disconnected
 enabled: disabled
 dpms: Off
 status: connected
 enabled: enabled
 dpms: On
 modes: 1920x1200 1600x1200 1280x1024 1280x1024 1152x864 1024x768 1024x768 800x600 800x600 640x480 640x480 720x400
 status: disconnected
 enabled: disabled
 dpms: Off
 status: connected
 enabled: enabled
 dpms: Off
 modes: 1366x768
 status: disconnected
 enabled: disabled
 dpms: Off
Date: Fri Oct 15 03:11:56 2010
 vhba, 20100822, 2.6.32-24-generic, x86_64: installed
 vhba, 20100822, 2.6.32-25-generic, x86_64: installed
 vhba, 20100822, 2.6.35-22-generic, x86_64: installed
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1)
MachineType: Sony Corporation VGN-TT11VN_X
 Socket 0:
   no product info available
 Socket 0:
   no card
ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.35-22-generic root=/dev/mapper/ssd-root ro quiet splash
SourcePackage: xorg
Symptom: display
dmi.bios.date: 03/11/2009
dmi.bios.vendor: INSYDE
dmi.bios.version: R2020M4
dmi.board.asset.tag: N/A
dmi.board.name: VAIO
dmi.board.vendor: Sony Corporation
dmi.board.version: N/A
dmi.chassis.asset.tag: N/A
dmi.chassis.type: 10
dmi.chassis.vendor: Sony Corporation
dmi.chassis.version: N/A
dmi.modalias: dmi:bvnINSYDE:bvrR2020M4:bd03/11/2009:svnSonyCorporation:pnVGN-TT11VN_X:pvrJ0034ZNW:rvnSonyCorporation:rnVAIO:rvrN/A:cvnSonyCorporation:ct10:cvrN/A:
dmi.product.name: VGN-TT11VN_X
dmi.product.version: J0034ZNW
dmi.sys.vendor: Sony Corporation
glxinfo: Error: [Errno 2] No such file or directory
 distro: Ubuntu
 codename: maverick
 architecture: x86_64
 kernel: 2.6.35-22-generic

Revision history for this message
webmeischda (webmeischda) wrote :
Revision history for this message
Marius (mariusknaust) wrote : [Bug 660901] [NEW] udev scripts running as root cannot use xrandr

Hi Alexander Steffen,

i want to write a script like you on a debian testing, can you maybe
send me your rules and the script? (<email address hidden>)

Ty very much,


Bryce Harrington (bryce)
affects: xorg (Ubuntu) → xserver-xorg-video-intel (Ubuntu)
Revision history for this message
Marius (mariusknaust) wrote :

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:

# VGA changed
KERNEL=="card0", ACTION=="change", RUN+="/usr/local/scripts/external-monitor.sh"


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

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

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

Revision history for this message
bugbot (bugbot) wrote :

Hey webmeischda,

Thanks for your interest in Ubuntu.

Thanks for testing maverick during its development period. Unfortunately it looks like this bug report didn't get attention during the maverick development period. But I see there's not been more comments on the bug since the release, which makes me wonder if this is still an issue for you?

If you've not seen this issue since maverick's release yourself, it may have been solved by kernel or X or other updates that occurred late in the release; if so, would you mind please closing the bug for us? Go to the URL mentioned in this bug report, click the yellow icon(s) in the status column and set to 'Fix Released'.

If you no longer have the hardware needed to reproduce the problem, or otherwise feel the bug no longer needs tracked in Launchpad, you can set the status to 'Invalid'.

If you are the original reporter and still have this issue, just reply to this email saying so. (Or set the bug status to Confirmed.) If you are able to re-test this against 11.04 Natty Narwhal (our current development focus) and find the issue still affects Natty, please also run 'apport-collect <bug-number>' while running natty, which will add fresh logs and debug data, and flag it for the Ubuntu-X development team to look at.

bugbot (bugbot)
Changed in xserver-xorg-video-intel (Ubuntu):
status: New → Incomplete
Revision history for this message
bugbot (bugbot) wrote :

We're closing this bug since it is has been some time with no response from the original reporter. However, if the issue still exists please feel free to reopen with the requested information. Also, if you could, please test against the latest development version of Ubuntu, since this confirms the bug is one we may be able to pass upstream for help.

Changed in xserver-xorg-video-intel (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.