Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an easy way to run an AppleScript or application immediately (or a brief delay of X seconds) after waking up from sleep?

I'm looking for a solution that doesn't involve a 3rd-party app.

share|improve this question
Why don't you want to use a 3rd-party app? It sounds like sleepwatcher is a good option. – jtbandes Mar 22 '12 at 22:45
Ditto, or Keyboard Maestro. – timothymh Mar 22 '12 at 23:57

Yes indeed there is, and it is detailed in this, the Dragon Systems Software UK blog.

I do not believe it is possible without using some external software. The kernel notifies apps that register for registerSleepWakeInterest events, and AppleScript seems not to include the ability to register for this notification.

There's a code sample given in Apple's Kernel Programming Guide.

Bernard Baehr has even made source code for his application, SleepWatcher, available.

share|improve this answer
I was going to post this, but the OP doesn't want a third-party app. – jtbandes Mar 22 '12 at 22:54
Curious, does this work on going to sleep too? As in, running a script on going to sleep? – jmlumpkin Mar 23 '12 at 0:07
SleepWatcher can perform actions on going to sleep also, so yes. Of course you may need to take some action to delay sleep if what you want to do is going to take any time. – Adam Eberbach Mar 23 '12 at 0:09
You can run an AppleScript on waking using Power Manager. The AppleScript will be run within the active user session; this is important if your AppleScript is graphical or interacts with running applications. I am the author of the mentioned blog post. If you need help setting up the Power Manager event, please get in touch. – Graham Miln Jun 8 '12 at 11:15

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.