How to Schedule Your Mac to Wake Up with AppleScript
Modern Macs are able to wake up from sleep, and start up from a powered off state. One quick and easy use for this ability is to avoid waiting for your Mac to start up in the morning. We are going to create an event using Power Manager and AppleScript.
Modern Macs are able to wake up from sleep, and start up from a powered off state. One quick and easy use for this ability is to avoid waiting for your Mac to start up in the morning.
We are going to create an event using Power Manager and AppleScript. You can also create this event using just Power Manager’s System Preference; a previous recipe shows you how to schedule your Mac to power on without AppleScript.
How to Create a Wake Up Event in Power Manager
Launch AppleScript Editor: Applications > Utilities > AppleScript Editor.
Copy and paste the following AppleScript into a new document:
tell application "Power Manager Scripting" tell workshop set myEvent to make new event with properties {id:"myWakeEvent", name:"Wake up for work"} -- Create a daily trigger make new trigger daily at front of triggers of myEvent with properties {seconds from midnight:(8 * 60 * 60),availability:wake up, days: [Monday, Tuesday, Wednesday, Thursday, Friday]} end tell -- Deploy the event tell Event Store to store these events myEvent -- Clean up tell the workshop to empty end tell
Save the script: File > Save.
Run the script: Script > Run.
When you run the above AppleScript, a new event is created in your schedule.
You can run the AppleScript as many times as you like; each time the event is created, the previous event is overwritten. This is because the new event and any previous event share the same identifier.
The above AppleScript contains three pieces of key information. These pieces are the trigger daily’s properties. The properties are the seconds from midnight to wake your Mac, the availability, and the days of the week to schedule the trigger.
You can alter these properties and change the behaviour of the event to better suit your needs.
The trigger daily’s properties are not limited to just these three values. Below is an extract from Power Manager’s AppleScript dictionary:
trigger daily n [inh. trigger] : Trigger at a given time on given days of the week. Elements inherited from trigger Contained by events, local workshops. Properties
seconds from midnight
(integer) : Seconds past midnight to trigger. The trigger’s time is measured in seconds from midnight. Where 0 seconds equals midnight. Calculate seconds from midnight using the following formula:
seconds from midnight = (hours x (60 x 60)) + (minutes x 60) 5:30 am = (5 x (60 x 60)) + (30 x 60) = 19800 seconds from midnight 2:23 pm = (14 x (60 x 60)) + (23 x 60) = 51780 seconds from midnight
days
(list of Saturday/Sunday/Monday/Tuesday/Wednesday/Thursday/Friday) : Days of the week to trigger.
availability
(wake up/power on/power on or wake up) : Should the host be made available for this trigger.
scatter
(integer) : Scatter the date.
quiet
(boolean) : Minimise the notifications.
drift
(integer) : Acceptable drift.
Power Manager’s trigger daily AppleScript item
Take a look at the Power Manager AppleScript dictionary and our AppleScript Guide to get a feel for what else you can achieve with Power Manager on Mac OS X.