Locking your Mac with a keyboard shortcut

This is one feature that isn't directly supported by the otherwise extremely usable OS X.
There are a bunch of ways to do this most involving starting the screen-saver, either though hot corners or via QuickSilver triggers. However, I'm not very happy with starting the screen-saver to lock the screen, so I found the shell command for fast user switching and use that instead. Here's the script:
# lock.sh
/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
You can execute this script (remember to chmod u+x it first) via a keyboard shortcut by using QuickSilver triggers. Since it's easier to explain with screenshots, that's what I've done. Just remember that when you're selecting an item (shown in the last image), you need to hit '.' to clear the field so you can type in the path to your copy of lock.sh.

Post a Comment