Can’t connect to X!

Whenever I “su” to work as root and start an X application I get thoese “Can’t connect to X!” errors. This happens because the X-Server is run by the respective user. To avoid this problem you can “forward” the Xauthority from the user to root.

Use this snippet in roots .bashrc:

if [ -n "$DISPLAY" ]; then
  export XAUTHORITY="/home/<username>/.Xauthority";
  export DISPLAY=":0.0";
fi

Comments are closed.