I know this thread is old, but just in case someone is wondering. I was getting exactly the same problem:
unable to open display ":0"
I was trying to turn on two of my displays via SSH, but it failed with the message from above. Other thing I had to say is that I wasn't logged on the console of the physical PC, so, only the logon screen was there, but the displays were off because of the idle settings.
So, on my case, I had to add also the XAUTHORITY variable as follows:
#Turn on the main display
sudo DISPLAY=:0 XAUTHORITY=/run/user/121/gdm/Xauthority xrandr --output HDMI-0 --off
sudo DISPLAY=:0 XAUTHORITY=/run/user/121/gdm/Xauthority xrandr --output HDMI-0 --auto
#Turn on the second display
sudo DISPLAY=:0 XAUTHORITY=/run/user/121/gdm/Xauthority xrandr --output DP-4 --right-of HDMI-0 --off
sudo DISPLAY=:0 XAUTHORITY=/run/user/121/gdm/Xauthority xrandr --output DP-4 --right-of HDMI-0 --auto
Here I have to mention that I'm using Ubuntu 18 with gdm3 as display manager. You should check the path:
/run/user/121/gdm/Xauthority
It maybe different on your system. Also check your xorg.conf configuration. There I defined two screens as follows:
Screen 0 "Screen0"
Screen 1 "Screen1" RightOf "Screen0"
That's why I'm using the "--right-of" option.
Finally check the names of your ouputs by running:
sudo DISPLAY=:0 XAUTHORITY=/run/user/121/gdm/Xauthority xrandr -q
There you will get the right names. On my case: "HDMI-0" (main monitor) and "DP-4" (second monitor).
xrandr --output YOURSCREEN --off && xrandr --output YOURSCREEN --auto
? You did runxset
as root, didn't you? – dessert Oct 11 '17 at 11:19xset
?xset -display :0 -dpms
– dessert Oct 11 '17 at 11:31xset -display :0 -dpms
– Siv Oct 11 '17 at 19:24/etc/X11/xorg.conf
, especiallyOption "DPMS" "0"
could be helpful. Seeman xorg.conf
'sMONITOR SECTION
for more. – dessert Oct 12 '17 at 20:29but no xorg.conf? Could this be because Zentyal changes the locations of the X files?
– Siv Oct 13 '17 at 11:07man xorg.conf
'sDESCRIPTION
section for the whole list wherexorg.conf
can be located. – dessert Oct 13 '17 at 11:19