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.

  • Why don't you want to use a 3rd-party app? It sounds like sleepwatcher is a good option.
    – jtbandes
    Mar 22, 2012 at 22:45
  • Ditto, or Keyboard Maestro.
    – Tuesday
    Mar 22, 2012 at 23:57

1 Answer 1


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.

  • I was going to post this, but the OP doesn't want a third-party app.
    – jtbandes
    Mar 22, 2012 at 22:54
  • Curious, does this work on going to sleep too? As in, running a script on going to sleep?
    – jmlumpkin
    Mar 23, 2012 at 0:07
  • 1
    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. Mar 23, 2012 at 0:09
  • 1
    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. Jun 8, 2012 at 11:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .