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.
OFFSET=15
# 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.