This is a follow on question to

how to trap a suspend a resume from a bash script

How do you a trap the event that occurs when you close the lid and later reopen it from a bash script?

1 Answer 1


This StackOverflow question asks a very similar thing, just not bash-specific. The accepted answer states to try a program called Sleepwatcher for which the source is available.

From reading the source it seems like this program uses the apple-specific IORegisterForSystemPower function which allows the small C-daemon to be notified by the system before the syetm goes to sleep and after it wakes back up.

There is no generic ACPI daemon on Mac OS X that I know of.

You must log in to answer this question.

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