How to let KM know that the screen of macbook is closed

how to let KM know that the screen of macbook is closed?

I can't test this as I'm out of the country but it may be a starting point.

You might be able to use the Display Changed trigger and then use the following shell script to test for clamshell mode.

ioreg -r -k AppleClamshellState | grep '"AppleClamshellState" = Yes' | cut -f2 -d"="

This should return Yes or No depending on whether the screen is closed. You can then use this to perform conditional actions inside this macro or set a global variable for use in other macros.

I thought about using SCREENINDEX(Internal) but, for me anyway, that returns -1 when the laptop is closed -- which could well be the result when open as well.

But that sparked another thought -- how big is a closed laptop screen? Lo and behold, SCREEN(Internal,Right) = 0, and you should never get that if your laptop is open! So:

While @noisneil's is the "proper" way (though I think you should omit the = Yes from the grep?) you'll probably find the KM-native route to be quicker.

1 Like