Apple - Can I assign a keyboard shortcut to bring up the Mac OS X Login Window?

If you want to assign alt ⌥+cmd ⌘+L to lock screen without installing any programs, in 5 minutes, I suggest you doing these three steps:

  1. Create a Service in Automator and set "Service receives selected" to "no input" instead of "text".

  2. (Still in Automator) add 'Run AppleScript' (search on the left "apple" then double-click).
    In the script in place of (* Your script goes here *) you copy-paste:

    do shell script "'/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend"
    Save and exit. (You can name your service "Lock Screen".)

  3. Open System Preferences, Keyboard then in Keyboard Shortcuts tab and under Services you will find your service "Lock Screen" towards the bottom of the list.
    Now, click on "none" next to "Lock Screen" to assign ⌥⌘ L to your service. Actually I suggest rather ⌃⌥⌘ L because ⌥⌘ L is assigned in Finder.

Done.

(For step 2 cudos goes to Lauri Ranta!)


Press Shift-Cmd+Q. Make sure that "Reopen windows when logging back in" is checked. Press enter.

Thanks to Lion, when you log back in, everything will look the same.


Another way to log out to the fast user switching screen is to assign a shortcut to this shell command:

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

If you have the Alfred Powerpack, you can assign a shortcut to the lock action, but just typing "lock" doesn't take that much longer.

Tags:

Keyboard

Login