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
  • 197,895
  • 55
  • 485
  • 740
Siv
  • 48
  • Did you try plugging it out and in again? Seriously, did you try xrandr --output YOURSCREEN --off && xrandr --output YOURSCREEN --auto? You did run xset as root, didn't you? – dessert Oct 11 '17 at 11:19
  • Did you try to set the display directly in xset? xset -display :0 -dpms – dessert Oct 11 '17 at 11:31
  • Related: https://askubuntu.com/questions/854246/command-doesnt-work-on-ssh-terminal-works and https://ubuntuforums.org/showthread.php?t=2220583 – dessert Oct 11 '17 at 11:33
  • @dessert I am remote to the site that has the server so I asked them to wiggle the mouse and press a shift key on the server's keyboard and that did not work. The screen just reports that it is in power save mode. I didn't run xset as root or use sudo and I did not run xrandr. – Siv Oct 11 '17 at 17:42
  • @dessert I did try running xset -display using two separate commands, ie: – Siv Oct 11 '17 at 19:08
  • export "DISPLAY=:0" then xset -dpms as per my question and that's when I get the "unable to open display ":0" error message. I will try and run it the way you have put it. – Siv Oct 11 '17 at 19:13
  • @dessert - Still same error when using:

    xset -display :0 -dpms

    – Siv Oct 11 '17 at 19:24
  • Also same error when using sudo. – Siv Oct 11 '17 at 19:24
  • @dessert - are you assuming I am on a terminal on the server or are you aware I am doing this using ssh remotely? – Siv Oct 11 '17 at 19:28
  • I am aware of that, but out of ideas for now. – dessert Oct 11 '17 at 19:43
  • @dessert my question was more about waking the monitor than the things I had tried being wrong, I was hoping someone like you with more knowledge could point me at some subsystem like power saving that I could configure so that it was in a "no power saving" mode? – Siv Oct 12 '17 at 20:08
  • OK, let's see: You could (carefully!) play around with the settings for the monitor in /etc/X11/xorg.conf, especially Option "DPMS" "0" could be helpful. See man xorg.conf's MONITOR SECTION for more. – dessert Oct 12 '17 at 20:29
  • When I list the contents of /etc/X11 I see this: app-defaults openbox xkb Xresources Xsession.options default-display-manager rgb.txt Xreset Xsession xsm fonts xinit Xreset.d Xsession.d

    but no xorg.conf? Could this be because Zentyal changes the locations of the X files?

    – Siv Oct 13 '17 at 11:07
  • Please consult man xorg.conf's DESCRIPTION section for the whole list where xorg.conf can be located. – dessert Oct 13 '17 at 11:19
  • I did "sudo find / -name Xorg.conf" and it came back with no results? So it would appear I have no Xorg.conf? Also did same for xorg.conf and no joy either unless I am getting the find command wrong? – Siv Oct 15 '17 at 13:50

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

  • Thanks for your comment, this was a long time ago and I got sick of Zentyal and the HP Server it was running on causing problems like this so now we have a Dell Server running ClearOS and everything works like a charm, so I don't need to fix it any more, however I have this page bookmarked and if I hit this issue in the future I will at least know how to fix it.

    Thanks again.

    – Siv May 27 '20 at 19:31