16

I know this has been asked many times (Is there a similarly fast alternative to Crtl + Shift + Eject for new Macbook that lack eject keys?) but the hotkey combination does not work on my MacBook Air that has no eject button running 10.7.

So, what hotkey combination can I use to lock the screen?

B Seven
  • 801

6 Answers6

16

Edit: pressing the power key on a MacBook Air while holding control and shift does not work in 10.7. The power key can only be substituted for eject in 10.8 and later versions of OS X.

Putting displays to sleep only locks the screen if this setting is enabled:

You can also put displays to sleep in 10.9 by running pmset displaysleepnow.

Another way to lock the screen is to enable the Keychain menu extra from the preferences of Keychain Access and then select Lock Screen from the menu extra:

An alternative way to lock the screen is to log out to the fast user switching screen. You can do it by running

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

or by using the lock action in Alfred:

Lri
  • 105,117
  • I am asking about 10.7 because that is what I am running. Not 10.9. Not 10.8. There is no eject button. The "require password" is set. – B Seven Nov 22 '13 at 22:08
  • Keychain menu item does not work reliably. (Or it does not lock the screen immediately after it's dimmed) – Display Name Oct 07 '15 at 17:53
13

MacBook Air replaces eject button with power button. Use this instead:

Update 2013-11-23: I apologize for not reading the question carefully. I missed the part where you want to actually lock the screen. The combination key below only turn off the screen without actually locking it.

Control+Shift+Power/Eject Button

If you want to enter sleep mode (where you also lock the screen), the answer provided above is correct. The combination key to enter sleep mode is:

Option+Command+Power/Eject Button

sayzlim
  • 4,778
8

Here's something for anyone who, like me, scoured the web for a simple Mac equivalent to "Windows-L" to lock the screen, and found that all the solutions either required third-party software you don't want or a special key that doesn't exist on your (generic external) keyboard. The following worked for me in Mavericks (10.9.3)

  1. Launch the "Automator" application and create a new document of type "Service"
  2. Specify that the service receives "no input" in "any application"
  3. Add the "Run Shell Script" action to the service
  4. Paste the following into the "Run Shell Script" action's text area: /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine
  5. Save the service as "Start ScreenSaver" and quit Automator
  6. Launch the "System Preferences" application and go to the "Security" preference pane
  7. Under the "General" tab, enable "Require password [immediately] after sleep or screen saver begins"
  8. Now go to the "Keyboard" preference pane, "Shortcuts" tab, "Services" list item, and find your "Start ScreenSaver" service under "General" near the bottom of the list on the right, and double-click it.
  9. Press your chosen keyboard shortcut (I like control + option + command + L, so I can just mash all three modifier keys together and hit L for lock)

EDIT: I had trouble after an upgrade to OSX El Capitan. I was using the more-succinct AppleScript content:

activate application "ScreenSaverEngine"

which I thought should have been more future-proof than the shell-script incantation of step 4, but the first time I used it, it claimed to be unable to find ScreenSaverEngine. This was fixed after I started ScreenSaverEngine.app once explicitly from the command-line:

open /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app
jez
  • 281
  • 1
    Or this variant might be more future-proof: instead of the "Run Shell Script" action with its long incantation, use a "Run AppleScript" action with the text activate application "ScreenSaverEngine" – jez Jun 07 '14 at 23:03
  • 1
    Now I must enter password every time after screensaver. How many threads keep proposing the same broken solution. – Ivan Balashov Aug 15 '15 at 19:47
  • With today's screens, what other use is there for a screensaver anyway? If you don't want the screen to password-lock automatically after x amount of time, simply configure the screensaver so that it doesn't start automatically after x amount of time. Then it will only come on when you deliberately lock it. – jez Aug 16 '15 at 17:46
  • To save battery – Ivan Balashov Aug 16 '15 at 17:49
  • System preferences -> Energy Saver -> Display Sleep works independently of the screensaver, and is a more effective way of saving battery (since a screensaver doesn't actually turn off the screen and may use some CPU itself). – jez Aug 16 '15 at 17:52
  • This contradicts #7 in your solution, which says "immediately after sleep" – Ivan Balashov Aug 16 '15 at 18:14
  • I'm not sure why your comment disappeared, but I actually I just did try it. My screen went to sleep after 1 min of inactivity, and I was asked to enter my password. – Ivan Balashov Aug 16 '15 at 18:34
  • Yup, same for me. I had thought Display Sleep and System Sleep counted differently regarding the password setting but I guess I must have been thinking of Windows (at least one of my Windows machines behaves the way you want). So you're right, a password is needed even if you didn't intend to lock. Is there a better solution? – jez Aug 16 '15 at 18:40
  • The best I could find is to enable keychain access extra menu, and use it from there. http://apple.stackexchange.com/a/111493/45039 There must be a better way, e.g. with some console command. But never came across it yet. – Ivan Balashov Aug 16 '15 at 18:49
1

I set up my screen saver with a "hot corner" in System Preferences (so that the screen saver starts when I move my mouse into the corner). This in combination with setting the security for password to be "immediately" required, means that you have a simple way to lock the screen.

Steve
  • 11
1

I simply set security to ask for password immediately on sleep, and use the power/sleep button to lock my MBA (OS X Yosemite).

nohillside
  • 100,768
1

Go to settings, Security & Privacy, General then set password "immediately"

After setting that, you may now use the shift+control+power button for mac book air.

It will be put to sleep mode or lock screen then when you need to use it again, it will ask for password.

user193746
  • 11
  • 1