Detect if lid is opening/closing

Hello all,

I would like to do some actions in my app(specifically writing some logs) when laptop is waken up/slept due to lid opening/closing.

How can I detect that? Is there Notification emitted or API I can check to achieve that?

I have read I could use Advanced Configuration and Power Interface (ACPI) but I havent found a lot of documentation.

Thanks in advance

Replies

Could this provide a first hint at a solution ?


h ttps://unix.stackexchange.com/questions/11724/how-to-detect-a-laptop-hibernate-resumeclose-lid-open-in-osx-from-a-bash-scrip


Good luck.

The power management APIs, like

IORegisterForSystemPower
, tell you about the system’s power state, which is not directly tied to the lid state. A MacBook has be asleep with the lid open and awake with the lid closed.

As far I know there’s no way to get the lid state directly.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"