Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This is a two part question. A practical, "how to" question is first, and then I ask for configuration suggestions.

First, I put my displays to sleep at night, and I would like to be able to wake the display remotely. Is there a command line utility I can use to wake it via SSH? I know about WakeOnLan, but that seems like overkill.

Second, the whole reason for me wanting to wake my display remotely has to do with how Lion's power savings settings changed. The Apple infrared remote no longer wakes the display. This is a huge deal for a machine I originally bought to be a combined desktop/home theater pc, since it defeats half of its purpose. So, does anybody have any ideas/suggestions what to do about this? This is open ended, I know.

share|improve this question

6 Answers 6

You can use

pmset schedule wake "01/01/2012 20:00:00"

to wake up a sleeping display on an otherwise "awake" Mac. Replace the date/time part with current time of course.

share|improve this answer

The easiest way to do this over SSH is to use caffeinate -u (available since OS X 10.9 I think) to simulate user activity.

Add the flag -t 5 to specify a timeout of 5 seconds (else you'd have to ctrl+c out of caffeinate, it seems).

share|improve this answer
there you go a (+) for your answer that no one has been paying attention to. I have so many of those my self, where ppl come ask a question newer to come back to check for a answer. – Buscar웃 Feb 27 at 17:36
This is great, Thank you! – Wade Williams Nov 11 at 7:04

Waking the Display from the Command Line

For waking your display remotely, try running an AppleScript on the command line:

osascript -e 'tell application "System Events" to key code 123'

This will simulate pressing the cursor key and should make Mac OS X 10 believe a user is active on the computer.

This AppleScript is based on the answer, How do I automate a key press in AppleScript?

Waking the Display after Waking with the Remote

If you are waking your Mac using the remote and the display is not powering on, try Wake Assist. It is not designed for this situation but might just work.

Wake Assist simulates a mouse click after your Mac wakes up. The mouse is clicked twice in the upper-left of your main display. Wake Assist will do nothing if it detects a user but if the computer wakes and is idle, then the mouse is clicked for you.

share|improve this answer
The AppleScript thing did not work for me. I get a black image from screencapture even after waiting a few minutes. – lhf Jul 18 '12 at 18:02
Have you tried any other simulated key presses - maybe the cursor key is not enough? Do you require a password on wake? – Graham Miln Jul 19 '12 at 9:34
Worked fine for me on OS X 10.6 – claytron Nov 14 '12 at 23:15

wuc wrote:

You can use

pmset schedule wake "01/01/2012 20:00:00"

to wake up a sleeping display on an otherwise "awake" Mac. Replace the date/time part with current time of course.

However, that didn't work for me on a circa 2008 iMac running 10.9.1 or a late 2010 MacBook Air running 10.9.2. I'm not sure if this has something to do with Mavericks' energy management or the hardware, or what.

I was able to get it to work by setting the wake time to be 15 seconds into the future. Occasionally I was able to get it to work with the setting as low as 12 or 13, but not reliably. But there may have been other factors I didn't realize at the time, but 15 worked, so I used 15.

But how do you calculate 15 seconds into the future programmatically?

I used gdate from the GNU Coreutils package (date in OS X might be able to do this, but if it can, I don't know how, and I already had gdate installed):

[to use date instead of gdate use alias set_wake_time='date "-v+${OFFSET}S" "+%D %T"']

Here's the script I used:

#!/bin/zsh -f

# how many seconds into the future we want to wake the display
# 15 seems to work reliably. YMMV.

# to calculate the time, we need `gdate`
alias set_wake_time='/usr/local/bin/gdate --date "+${OFFSET} sec" "+%m/%d/%g %H:%M:%S"'

# this is where we set the wake command
# if it doesn't succeed the script will exit immediately
/usr/bin/sudo /usr/bin/pmset schedule wake "`set_wake_time`" || exit 1

# if you were not testing this, you'd probably want to end at the
# next line. Just remove the leading '#'
#exit 0

### Everything below this line is only needed during testing ###

# this tells the display to sleep
# because we can test waking the screen up unless it's asleep
pmset displaysleepnow

# for testing purposes: now the script will pause for $OFFSET seconds
sleep $OFFSET

# For testing purposes:
# after $OFFSET seconds, this sound will play 3 times.
# by that time, the display should be awake
# I did this to help me know when I had set OFFSET too low

afplay /System/Library/Sounds/Glass.aiff

afplay /System/Library/Sounds/Glass.aiff

afplay /System/Library/Sounds/Glass.aiff

# script is done
exit 0

Everything after the '#######################################################' can be removed once you have finished testing.

share|improve this answer
date -jv+15S will do the trick of calculating the date 15 seconds in the future from now. The -j switch prevents date from trying to set the system clock. – mike Apr 4 '14 at 15:29
Oh, hey, thanks! – TJ Luoma Apr 7 '14 at 14:36
The command date -jv+15S "+%m/%d/%Y %H:%M:%S" will put the 15 seconds in the future into the correct format for pmset. – Aaron D May 1 at 7:47
According to the OSX 10.10.3 pmset manpage, there is a 'pmset relative wake seconds' option as well. Might be worth investigating as well. – JS. Jul 15 at 21:05

Oh, how I wish I had enough rep to upvote @wuc's answer the 10 times it deserves for this maddeningly frustrating problem (or to at least be able to leave a simple comment with the praise it deserves).

Apple, in its paternalistic wisdom, added a "feature" that intentionally made it harder to wake the display on Lion and Mountain Lion. This has made life much harder for those desiring to remotely wake the display (using IR remotes or via VNC) to interact with their Macs . For some reason, this became more pronounced with OS X 10.8.2.

Using pmset was a marvelous workaround for me.

Step 1: Login to the remote machine using ssh myname@ (replace with an appropriate username and ip for the remote Mac).

Step 2: Wake up the display using pmset schedule wake "06/27/2013 04:20:00" (with an appropriate future date of your choosing).

share|improve this answer

Option if you don't want to use gdate:

  • Enable SSHD (Remote Login) under System Preferences, Sharing
  • Enable 'Wake for network access' under System Preferences, Energy Saver

put this code in a file like '' in your home folder:

shopt -s expand_aliases
#NB: 7 is the waiting interval. Works for me. Increase as needed. 
alias myDate='date -v+7S "+%m/%d/%Y %H:%M:%S"'
echo MacBook will wake up at: `myDate`
echo yourMacPW | sudo -S pmset schedule wake "`myDate`"
  • Make it executable with 'chmod +x' and enter your password if you like. Otherwise drop the echo and -S.

If you want to automate this process to work from a windows machine:

  • Get PuTTY and a command line WakeOnLan tool (ie Aquila on SourceForge)
  • Make a one line text file containing './'
  • write a batchfile like this:

    @echo off
    cd "C:\Program Files (x86)\Aquila Technology\WakeOnLAN"
    wakeonlanc.exe -w -mac 00:00:00:00:00:00
    ping -n 1 | find "unreachable"
    if %ERRORLEVEL% EQU 0 GOTO tryAgain
    cd C:\putty
    putty.exe -ssh -l yourUser -pw yourMacPW -m c:\putty\macWake.txt

Things you need to change: your IP, your MAC address, the word 'unreachable' may not be what you get - you might get 'timed out'. Storing a root password in plain text is of course, not a good idea, but this how to do it completely automatically from Windows to OSX.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.