Log off the current user upon closing the lid

javidmajdi
New Contributor

Hi,

Is there anyway to set the OS to log off the user when the lid is closed on Sierra?

What I'm trying to accomplish is to run a script from JSS which triggers at the log off, however, 99% of the time users don't log off and just close the lid.

Any help is much appreciated.

Thank you in advance.

3 REPLIES 3

Look
Valued Contributor III

You might want to be careful altering lid closure behaviour, it's generally set to sleep/hibernate the machine immediately and people usually follow this up by immediately putting it in a bag or other thermally enclosed space. The few times my machine has woken or not gone to sleep properly in my bag it has got so hot it's not a process I would want to repeat often!

sdagley
Esteemed Contributor II

@javidmajdi Rather than try to run a script from your JSS, you'd be better off with a script you've installed locally on the user's machine that checks for the lid being closed with a user logged in, and are triggering periodically via a LaunchDaemon. See this article on StackExchange for some ideas:

https://apple.stackexchange.com/questions/104486/macbook-air-pro-run-script-upon-lid-close

Morningside
Contributor II

@javidmajdi Did you find a solution you liked for triggering a script when the lid closes? I have the same problem in my school. Kids close the lid instead of log off, and even those that do, never bother to click ok in the warning screen.