2

I am aware of the options suggested in Possible to run scripts on sleep and wake?.

I am ideally looking for a native option that doesn’t require installing a third-party app or binary.

The closest I found is SleepWatcher but it requires installing a third-party binary using brew install sleepwatcher.

Thanks!

1

Limited Time

There is no built-in way to run a script before sleep on macOS. You must use a third party tool to trigger your bash script.

The time available for your script, after the pending sleep notification but before the sleep, is deliberately limited by macOS. See Fleeting Sleep Trigger for an overview of the problem.

  • +1. I'm not aware of any built-in feature which would allow this without a 3rd-party application. If such a thing existed, SleepWatcher would not have been necessary. I would add Keyboard Maestro as another good option which does this plus many, many other things, which maximizes the "value" of having a 3rd-party tool installed and running, vs having a specific one-off daemon running just for this. – TJ Luoma Aug 14 at 9:59
  • 1
    Re the fleeting sleep trigger note. The important bit is any work should be done when the machine wakes up.not before it sleeps. So the real question is what do you want to do before sleeping and find a better way if doing it. – Mark Aug 14 at 16:25

You must log in to answer this question.

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