Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I wonder if there is some way to customize the lock screen feature of my macbook air (running Mountain Lion) in such a way that:

1: When I close the lid, and then open it, the screen is not locked (that is, I do not have to write my password).

2: When I explicitly put the macbook air to sleep (with Power Button + Sleep option), and then wake it from sleep, the screen is locked (that is, I do have to write my password).

Thanks in advance


@bmike Thanks for for your response, but I think I did not explain clearly what I wanted. I wanted an easy way to put the computer to sleep and either not been asked for a password when it wakes (if I close the lid) or been asked for a password (when I explicitly put the computer to sleep).

@George Oross: Thanks for your response. I tried to find in the apple developers website some info on how to detect those signals, but made no advance.

I think that the best way to do that is to enable the "lock screen" menu item (via Keychain Access). If I want a "secure sleep" I first lock the screen through the menu and then close the lid to put it to sleep. If I want a "non-secure sleep" I simply close the lid.

share|improve this question
    
Can you limit the amount of time that the screen lid is closed in item 1? The machine will sleep when you close the lid and there is no way around that short of hacking the firmware or OS severely. Item #2 can be addressed by simply choosing the log in screen rather than explicitly sleeping the mac. If this sounds good - let me know and I'll write up a real answer covering the details. –  bmike Sep 28 '12 at 14:35
add comment

2 Answers

up vote 4 down vote accepted

No. What you want is not possible.

When the screen is closed the behavior is the same to the user as if it went into sleep from another reason such as pressing the power button. There isn't any way to have closing screen sleep (called clamshell sleep) set to have a different effect than any other kind of sleep through user-accessible preferences. If you have your mac set to require a password after waking in the security preferences then the mac will ask in both cases upon waking.

However, the mac internally codes the reasons for sleep differently. So the computer can tell clamshell from idle sleep, and also can tell if the mac went to sleep for another reason such as power button press, low power or high temperature. Therefore it is possible that a third party hack can use these codes to enable different behavior. I could not find one, though.

When the mac wakes up there are similar codes generated by the OS so that it knows if the computer was woken by opening the clamshell, wiggling the mouse, pressing the power button, waking for network access and so on. This seems to create another opening for a third party solution.

share|improve this answer
add comment

If you don't want to keep the Keychain menu extra in the menu bar, you could also assign a shortcut to a shell command like this:

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend && osascript -e 'tell app "System Events" to sleep'

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.