Mike West — Web Application Developer

I’ve tried a few different methods to walk away from my Mac without worrying about jackass coworkers sending e-mails and IM messages on my behalf, and after a bit of experimentation with various screensavers and applescripts, finally hit upon a solution that I’m happy with. It’s pretty simple, and leverages the power of Quicksilver triggers to make the process of locking my computer absolutely second-nature.

Terminal Magic

First, open up a terminal window, and copy and paste the following line:

echo "alias lock='/System/Library/CoreServices/Menu\\ Extras/user.menu/Contents/Resources/CGSession -suspend; exit;'" >> ~/.bash_profile

This adds an alias to your bash profile that gives you the ability to simply type lock at the command line to securely suspend your current session. I always have a terminal window open, so this was a good first step for me, and might reasonably be enough for you if you’re also a terminal geek. However, adding Quicksilver into the mix makes the process more flexible.

Triggers

We can create a trigger to bind a hotkey to the terminal command we’ve just created. Whenever I hit ???, my computer locks itself down; it’s trivial.

Bring up Quicksilver’s preference screen by hitting your Quicksilver hotkey (mine’s bound to ?-Space), then ?-Comma. Select “Triggers” from the menu at the top, then create a new custom trigger by hitting the plus button near the bottom and selecting “Hotkey.” Set this new trigger to run our lock command by hitting “.” to enter text entry mode, typing “lock”, then tabbing to the next field and selecting “Run a Text Command in Terminal” (if you don’t have this command, make sure the Terminal plugin is installed).

Once the trigger is created, give it a hotkey by double clicking on the trigger (or clicking on the “info” icon in the bottom right-hand corner), then clicking on the “Hot Key” field, and hitting the keys you’d like to assign. I chose ???\ because it requires both hands, and isn’t something I could possibly hit by accident.

And that’s all there is to it! You can now lock your computer with impunity! Enjoy your new-found power.

Mike West is a web application developer living in Munich, Germany. Professionally programming for the web since 2000, he's available for contract work now a web developer at Yahoo! Germany. Read Mike's bio, or drop him an e-mail.

Recent Articles


Comments

nice to know how to do it from the command line, but there is actually a way built into OSX to show a padlock in the menu bar and lock the screen from there.

http://www.whatdoiknow.org/archives/000957.shtml

Posted By: Jehiah Czebotar 21. January 2007, 12:55

Hey Jehiah, thanks for the tip! I’ve tried something like this in the past, but I couldn’t find a quick way to bind it to a hotkey. Tying a locking action to a Quicksilver trigger is really a killer feature for me… I don’t think I’d lock my machine half so consistantly if I had to mouse around for a bit before getting up from my desk.

For the record, the other option I tried for a while was a simple hot-corner that turned on a passworded screensaver. That worked fine… too well, actually. I’d find myself locking my machine without intending too, simply because I moused too far over to one side of the screen. The option I’ve outlined here is pretty much the best compromise I’ve come up with.

Posted By: Mike West 21. January 2007, 13:05

Funny that Windows does this out-of-the-box with Start+L :p

No doubt, the next generation of Mac’s will let you (un)lock your session by swiping your hand across your screen ;)

Posted By: Bruce Boughton 21. January 2007, 15:03

You’re right, Bruce. I don’t really understand why it isn’t a built-in option on the Mac. It’s a pretty basic piece of functionality, and a critical one when in a business enviornment.

But overall, OS X does enough right that I’m willing to forgive it these little missteps. :)

Posted By: Mike West 21. January 2007, 17:26

I don’t use a Mac so I don’t have a clue what I’m talkign about, but can’t you put a timed even on the corner so it doesn’t activate until the pointer has been there for let’s say 5 seconds?

@Bruce, Mac does this too, if you have quickswitch activated - as Mike says it’s basic ;)

This is readworthy for you guys - google solves all problems™ ;P

http://www.macworld.com/weblogs/macosxhints/2006/01/lockscreen/index.php

Posted By: gunnar 7. April 2007, 21:36

Comments Closed

Comments are closed after 6 weeks to avoid the icky comment spam we all loathe. Sorry if you missed the opportunity, but you can always drop me an e-mail!

flickr Photostream

Yahoo!'s Munich Office
atom:title
atom:title
atom:title