I couldn't get any program requiring x11 (e.g. gedit, nautilus) to work with sudo. Using gksudo would just fail silently, while on terminal I received the following error:
sudo nautilus ** (nautilus:4160): WARNING **: Command line `dbus-launch --autolaunch=cced40b4aa1d252bc89d3a6a0000000a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n Could not parse arguments: Cannot open display:
With the help of a friend I managed to find a workaround: if I run
as an unprivileged user and then
export DISPLAY=:0 as root after a
sudo su, it finally works (without the xhost step I'd get an undefined protocol error). However I don't understand why I have this problem in the first place, and it is a laborious workaround - I thought of adding an `export DISPLAY=:0" in root's .bashrc but that's only called if I'm suing, not if I just sudo.
Any ideas on how to properly solve this issue?