2

If the monitor on a remote Ubuntu Server goes into sleep mode, is there a way that you can wake it up from an SSH command line?

I have tried using export "DISPLAY=:0" and then xset -dpms to try and turn off power saving modes but I get:

 Invalid MIT-MAGIC-COOKIE-1 keyxset:  unable to open display ":0"

The server is Ubuntu 16.04.3 LTS running the Zentyal web front end. There is a UI on the remote server that local admins can log into, but for some unknown reason after applying updates via the Zentyal web admin screen and re-booting the screen seems to go into power save and wiggling the mouse or pressing a key won't wake it so I am trying to force the server to wake up the screen.

muru
  • 207,228
Siv
  • 48
  • 1
  • 6

1 Answers1

3

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).