Quickly locking your computer in OS X

In Windows it's easy to your screen; you can do it after pressing ctrl+alt+delete, or my personal favorite, start menu key+L. For some unknown reason though, Apple has decided that it's not terribly important to be able to quickly your screen. I always forget to do this on my new computers, so when I had to my screen last week it jarred my memory.

Launch Keychain Access (Applications > Utilities > Keychain Access) and open Preferences. On the General Tab check off Show Status in Menu Bar.

Keychain Access - Preferences

You're done with Keychain Access and it's safe to quit it. Now, if you look in the menu bar you'll see a new icon that will let you quickly your screen.

Keychain Access Menu

Using AppleScript

I almost never use AppleScript so I wasn't even going to attempt writing one, but I was curious if you could add a hotkey to access the Screen item from the keychain menu. I found the answer in AppleScripting the Keychain menu at macosxhints.com.Create a new AppleScript with the following code and then use a utility like ThisService to register it as a service with a menu shortcut (like cmd+shift+L).

activate application "SystemUIServer"
tell application "System Events"
 tell process "SystemUIServer"
 	repeat with i from 1 to number of menu bar items of menu bar 1
 		tell menu bar item i of menu bar 1
 			click
 			try
 				if name of menu item 1 of front menu is "Lock Screen" then
 					click menu item "Lock Screen" of front menu
 					exit repeat
 				end if
 			end try
 		end tell
 	end repeat
 end tell
end tell

Anyone know of a better (or just different) way?

 

3 Responses to “Quickly locking your computer in OS X”

  1. Rob Says:

    This seems to be about the same as setting a screen-saver/sleep timer and then from the Security Pref's Pane choosing "Require password to wake this computer from sleep or screen-saver".

    For convenience, the screen-saver can be activated using a hot-corner, or sleep can be invoked using Ctrl+Eject, S (for sleep) (on extended keyboards), or the power button, S on a laptop.

  2. Brian Says:

    Use Quicksilver: Cmd-Space, L O C K, Enter, or just assign a trigger to that action.

  3. Corey Gilmore Says:

    Brian – that's great! I mainly use Quicksilver for launching applications, so I've never looked at triggers before. It's much cleaner than the AppleScript solution.

Leave a Reply


© 2007-2012, Corey Gilmore | Posts RSS Feed | Comments RSS Feed | Contact

 

The views expressed on these pages are mine alone and not those of any past or present employer. All information presented on this site was obtained lawfully and not through disclosure under the terms of an NDA.