Wake a Mac display from sleep via SSH

5

1

I'm using Jenkins as a CI server, where I'm SSHing into an iMac running OS X Mountain Lion (10.8.4) to run some UIAutomation integrations tests on an iOS app. The iMac actually sits 10 ft from me (but across a table) so I'm able to see the screen. However, the tests don't wake up the display, so I often can't see them.

Is there a way to wake up the display from the terminal once Jenkins has SSHed in?

So far I have tried using Applescript to press an arrow key, and using the Wake Assist application. I also tried setting the wake schedule to be the current date. Finally, I tried using the caffeinate command: caffeinate -t 300 &. The computer's "Wake for Wi-Fi access" checkbox is enabled.

So far my best workaround is to just set the iMac to stay awake for atleast 3 hours. However, it'd be nice to keep normal sleep behavior, as I hypothesize that the screen waking from sleep would alert me visually that the integration tests are running. It's also significantly cooler :)

MaxGabriel

Posted 2013-06-25T04:47:18.943

Reputation: 173

Answers

4

The Screen Saver is a standalone program which is started and stopped by the system according to the set triggers, such as time, or a hot corner, and appears in the process status list, but only if it's running.

I was able to stop the screensaver by:

killall -1 ScreenSaverEngine

It starts again when I trigger it with a hot corner, and by the normal timer, I just checked.

Hack Saw

Posted 2013-06-25T04:47:18.943

Reputation: 231

1This was helpful when my Mac Pro got stuck in the screensaver and the shift-ctrl-eject key combo was not available because I was temporarily using a PC keyboard with no Eject key (shift-ctrl-F12 did not work). – Fred Yankowski – 2019-10-10T15:45:48.263

Hm.. I get No matching processes belonging to you were found (or a similar message when run with sudo), both on my machine and the iMac. – MaxGabriel – 2013-06-25T18:03:34.687

I'll try listing all processes to see if it's there. – MaxGabriel – 2013-06-25T18:03:56.887

Note that it'll only be there if the screensaver is running. – Hack Saw – 2013-06-26T00:04:11.920

Thanks for asking about this, I love the idea of waking up the screen to remind me to have a look at it. – Hack Saw – 2013-06-26T09:32:39.090