wuc napisał:
Możesz użyć
pmset schedule wake "01/01/2012 20:00:00"
aby obudzić uśpiony ekran na Macu „budzącym się inaczej”. Zastąp część data / czas bieżącą godziną oczywiście.
Nie działało to jednak dla mnie na komputerze iMac z 2008 r. I wersji 10.9.1 lub MacBooku Air z 2010 r. I wersji 10.9.2. Nie jestem pewien, czy ma to coś wspólnego z zarządzaniem energią Mavericks, sprzętem, czy co.
Udało mi się go uruchomić, ustawiając czas budzenia na 15 sekund w przyszłość. Czasami mogłem sprawić, aby działał z ustawieniem tak niskim jak 12 lub 13, ale nie niezawodnie. Ale mogły istnieć inne czynniki, o których wtedy nie zdawałem sobie sprawy, ale 15 zadziałało, więc użyłem 15.
Ale jak obliczyć programowo 15 sekund w przyszłość?
Użyłem gdate
z pakietu GNU Coreutils ( date
w OS X może to zrobić, ale jeśli to możliwe, nie wiem jak i już gdate
zainstalowałem):
[używać date
zamiast gdate
używać aliasu set_wake_time = 'date' -v + $ {OFFSET} S "" +% D% T "']
Oto skrypt, którego użyłem:
#!/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
Wszystko po „#################################################################### ######### 'można usunąć po zakończeniu testowania.