Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): No such file or directory in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php on line 1786

Warning: Cannot modify header information - headers already sent by (output started at /home/markwheadon/markwheadon.com/blog/wp-content/plugins/statpress-reloaded/statpress.php:1786) in /home/markwheadon/markwheadon.com/blog/wp-content/plugins/wp-greet-box/includes/wp-greet-box.class.php on line 493
Locking your session in Mac OS X | Wheadon's Words; Mark's Mutterings
Main image
15th February

Windows-L for the Mac.

written by Mark Wheadon

The need

Coming to Mac OS X from Windows (XP and Vista), I missed being able to lock my session using a simple key-chord. I work in a shared office so it’s sensible to lock the session every time I walk away — something I do regularly.

In Windows, you simply press Windows-L and that’s it — time to go. Mac OS X Leopard doesn’t provide anything as succinct as standard, but there are ways.

Firstly, there are a couple of solutions that are accepted as standard ways of doing this — but unfortunately both have problems. I’ll cover these methods first in case they work for you, and then I’ll cover a solution that really is as quick and easy to use as the Windows’ lock screen key chord.

Partial solution number one: use a hot corner

A hot corner allows you to drop into the screen saver by moving the cursor to a chosen corner of the screen. To do this, first go to System Preferences->Desktop & Screen Saver and click on Hot Corners… Then select Start Screen Saver for one of the corners:

hot-corner-screensaverNow, when you place the cursor in that corner (I chose the bottom-left), the screen saver will start.

Of course, this doesn’t help unless your system is configured to require a password when woken from the screen saver. You can set that in System Preferences->Security:


And that’s it. Now, before you walk away from your Mac, just drop the cursor into the bottom-left corner of the screen.

However, there is a problem with this method — at least for me — as I don’t want the system to prompt for a password on wakeup. I end up typing my password far too often — every time I’ve left the machine alone long enough for the screen saver to start.

What I want is the Mac to remain unlocked until I explicitly lock it. So, on to solution two…

Partial solution number two: select a pull-down from the menu bar

Here’s another way of locking the machine, and this one doesn’t require that you tick Require password to wake up this computer from sleep or screen saver.

The trick is to enable fast user switching in System Preferences->Accounts->Login Options:


which will then place your user name in the menu bar at the top of the screen.

When you want to lock the session, just click on your user name:login-window-from-userand select Login Window… and you’re done. (You can also achieve a similar result by ticking Show Status in Menu Bar in Keychain‘s preferences if you prefer.)

What’s my beef with this solution? The problem is that it’s still rather slow and fiddly — and it’s something I do regularly, so I want to just press and go, just as I did with Windows.

A full solution

To implement a full Windows-L style solution we need Dockables to provide us with an application that locks the Mac OS session, and Quicksilver to launch that application.

First, download and install Dockables from cocoaapp.com. This gives you a bunch of useful applications in a sub-folder of your Applications folder:


and the one we’re interested in is Lock Screen.

exit-quicksilver-windowNext, download and install Blacktree’s Quicksilver and run it to configure a new Lock Screen key-chord. Quicksilver will present you with its main window — just quit that and instead move to Quicksilver’s menu bar at the top of the screen and select Triggers… from the drop-down menu.


In the Triggers window that appears, click on the + at the bottom and select HotKey.


A new window will appear. Click on the first field and start to type lock screen. Quicksilver will rapidly find the Lock Screen dockable you installed earlier. Click Save.


Nearly there

You now have a new command, but with no trigger. So click on the None in your new command,

click-on-noneclick in the input field labelled Hot Key: and press the key combination you wish to use to lock your session from now on. (I chose alt+cmd+L because the obvious choice — cmd+L — is already used by Thunderbird — my email client.)


I suggest you don’t use the ctrl key as part of your hot key-chord. If you do then quicksilver presents this dialog every time you type the chord:


Now, having typed a key-chord (which doesn’t include ctrl), exit the Triggers window and you have yourself a new Lock Screen hot key-chord: alt+cmd+L in the example above.

And finally, tweak some settings

You need quicksilver to run at all times, so bring up Quicksilver’s preferences (available from the Quicksilver menu in the menu bar at the top of the screen):

quicksilver-start-at-loginand tick Start at login. You may also want to tidy up the dock a little — as quicksilver is running all the time I’d rather it didn’t appear in the dock and instead appeared in the menu bar:

alt+cmd+Lso I untick Show icon in dock (and I also tick the option check for updates):

quicksilver-full-prefsAnd that’s everything sorted. Any time you need your display locked, just type alt+cmd+L…


and walk away…


  1. Tim

    How long did that last photo take you to do? :-)

  2. Mark Wheadon

    About an hour from start to finish — high art takes time you know. :-)

  3. Marius

    I would like the keypress functionality to lock screen t come with the minimum of. installables. I don’t see a way to get past the need for something like QuickSilver as the Mac built-in key launching seems useless at best.

    However… You do not need Dockables. You can simply just launch the ‘ScreenSaverEngine’ app to lock your screen located at:


    (I’ve dragged this to my Dock for quick one-click locking so far, but have been unable to bind a key to it)

    So for Quicksilver users this is possible, but I’ve stopped using Quicksilver and am used to just using Spotlight. (I try to limit my dependence on extra apps)

  4. 31/03/2009

    Thanks Mark! This is exactly what I was looking for and works perfectly.

  5. Mark Wheadon

    Good stuff. Most people don’t comment, but being of an optimistic disposition I have to assume people find it useful.


  6. Pradeep

    Thanks Mark. Great Article. Keep posting such articles.

  7. Aziz Light

    Thanks for this tip. Unfortunately, it doesn’t work perfectly. if I double click on the dockable it works fine, if I launch it via QS it works fine, if I launch it using a QS trigger though I get a confirmation box asking me if I want to launch the app or quit…wierd..

  8. Mark Wheadon

    Hi – that’s one of the modifiers you’re using for your key-chord doing that (from memory, ctrl?) – that’s why I used cmd+alt. I guess I should check that out and add the information to the article, but in the mean time try cmd+alt+L as the key-chord and that dialog won’t pop up.


  9. Aziz Light

    Yay! It worked :) I changed the trigger from ctrl+cmd+L to alt+cmd+L and no popup appeared. I still did not understand why ctrl+cmd+L wasn’t working though..
    Anyway, Thanks a lot!

  10. Mark Wheadon

    I suppose the ctrl key must be used by Quicksilver to signify that you want confirmation of an action.

  11. Mark Wheadon

    OK, I’ve changed the article to steer people away from using ctrl as part of their key-chord.

  12. Johan

    Excellent tip! Thanks. I use cmd+L with a delay for 0.5 seconds – long enough not to collide with other applications using cmd+L while still short enough for me to wait :)

  13. Rokcet Scientist

    iAlertU – a car alarm for your Mac finally putting your Mac’s remote to good use (http://www.versiontracker.com/dyn/moreinfo/macosx/29578; it’s FREE and it works!) – is far simpler: download, install, start up, configure (set your preferences), and run.
    And it’s DARN effective!

    I run iAlertU on MacBook Pros in varying office and semi public access settings. Whenever I’m somewhere new I make sure the chirping sound is clearly audible when I arm iAlertU for the first time so that everybody within 80 feet gets the message. And that seems to do it. The siren has never yet screamed it’s head off ‘in earnest’ in the past 18 months. I would say that is effective, wouldn’t you?
    Ideal if you need to step away for a cup of coffee, a smoke outside, or a full service visit to the bathroom.

    Have fun!

  14. 24/05/2009

    Great posting!
    Fast to install, easy to handle, thank you!

  15. […] OSX: not quite as easy, but still doable.  See these instructions. Tagged with: easy, lock, mac, screen, security, shortcut, windows no comments yet « […]

  16. James M

    But what if I want to lock my keyboard, and not blank my screen?

  17. Mike Thorpe

    Just a quick note to say thanks for this. I know it’s only a little thing, but it means I can turn hot corners off now :)

  18. Zach

    I have switched to mac from windows because of my new job, and I have to say this is just one more thing on a long list of things that OSX does (rather, doesn’t do) that really pisses me off.

    Anyway, I use synergy at work to share my keyboard and mouse between the mac and my other computer (linux box). Locking the screen this way causes the synergy client on the mac to suspend as well, meaning I have to use the laptop’s keyboard to log back in. When using the hot corner/screen saver method, synergy still works.

    Also, is there really no way to have ctrl as part of my hotkey sequence without that stupid dialog? My linux box is set up to use ctrl-alt-L. I’d like to have them the same on both machines.

  19. Mark Wheadon

    I don’t know of any way of disabling or re-assigning the ctrl key’s function in quicksilver I’m afraid. (Does anyone else reading this know?)

    As an aside, I’ve found that whenever I change technology (particularly when forced to do so), I notice what is doesn’t do compared with my old way of doing things. Anything new / better doesn’t slap you around the face and interfere like something that’s missing or done differently does, so the minuses tend to be more obvious than the plusses, at least in the short term…

  20. Shane

    Thank you just what I was looking for. Just switched back to a Mac after 20+ years of working on a PC and need my familiar apps and functions.

  21. BenC

    Mark. Thanks for that article. I decided to go with the simple version (login window menu item…)

  22. Yoni

    Really was perfect – however your link to dockables needs to be updated. http://getdockables.com/

  23. Mark Wheadon

    Thanks Yoni — I’ve updated the link.

  24. Jim

    As of Mac OS X 10.6 Snow Leopard, there is one more way to accomplish this, without any extra or third party software.

    Use Automator to create and save a ‘Start Screen Saver’ service that accepts no input and is available to all applications. You can find the appropriate Automator action under ‘Utilities’. Then you can simply assign this new service a shortcut from the Keyboard Shortcuts preference pane.

    If you would prefer to lock the screen rather than use a screen saver, use Automator to run a shell script with the following command:

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

    Then set the keyboard shortcut as before. Huzzah!

    See this (more general) tip:

  25. Bahram

    Hey Mark, Thanks man, this is the first time i replied to a useful post saying thankyou.. you truly deserve it.. ive been lookin for this for AGESS

  26. […] your session in Mac OS X by Mark Wheadon http://www.markwheadon.com/blog/2009/02/lock-screen-mac-os-x/ i’ve been looking for that functionality for some time now. i didn’t like all those […]

  27. meme virus

    Even simpler w/o any screen saver.

    1] Enable the Lock Screen status on the menu bar (From Application > Key Chain Access > Preferences > Show Status in Menu Bar)
    2] Create a automator service using the “watch me do” user action recorder. (Automator – new service – drag the “watch me do” and click record and then do the Lock Screen action using the mouse.)
    3] Log back in and Save the Service as something
    4] Go to Keyboard Shortcuts (System Pref > Keyboard > Keyboard Shortcuts > Services – scoll to the end and there against “something”, double click to the right of it and assign a keyboard chord.

    Done !

  28. kjb

    Why is it that every other OS on the planet has a built in way to lock the screen with a keyboard shortcut and not OSX?? This should be built into the freaking OS not steps downloading a bunch of secondary apps. UGH…

  29. look

    thanks – good job and very useful. it took me 15 minutes.

  30. Jouni

    Locking the screen has been there for ages on all the other OS’s… maybe apple will “invent” it when 10.7 is launched? Just like they invented video chat w face time?


  31. 25/01/2011

    All of this is overkill.

    CMD+OPT+EJECT -> puts your system to sleep. Combine with “password on wake” in Prefs->Security and Bob’s your uncle! :)

  32. simon

    Even if you only put your display to sleep (Ctrl+Shift+Eject) and with “password on wake” enabled, you have yourself a locked screen with a shortcut.

  33. 10/03/2011

    @Simon: That’s brilliant.

  34. arek

    AWESOME!!! AT LEAST – thank you Mark :)

  35. Ben

    The ctrl key has no special meaning in QS (as far as I know). Its meaning only comes into play in the Dockable, which is an AppleScript Application created using AppleScript Editor. All AppleScript Applications behave this way when they are launched with ctrl pressed, and they have for at least a decade (Perhaps as early as System 7, when AS was introduced?). You can try hitting command-E to edit the script (though I bet it was saved as run-only). There are many other ways to accomplish the result without using an AppleScript Application, as described in the comments.

  36. Hari

    @Jim your solution worked the best, no need to have Keychain access icon showing, and I can lock and unlock from VNC. Thank you very much.

  37. […] aside, Mark Wheadon has an extensive article documenting various methods. It turns out Apple really doesn’t want you to use the keyboard […]

  38. BtDubZ

    Exactly what I was looking for! After searching through several worthless guides for methods that don’t work, I saw Mark’s comment on one and thought, what the hell. Well I tried it and it’s exactly what I need!

  39. Eithar

    Hello Mark, the quicksilver app isn’t even opening. It asks me if I want to install it in applications and I say yes. Then nothing happens so I can’t complete the process.

  40. Mark Wheadon

    So far as I know it’s a .dmg file you download. In which case you double click on the .dmg file to mount it, and then drag the quicksilver application that appears in the finder window into your Applications folder to install it.

  41. […] Mac is not designed to provide you with such an option. However, this article explains a workaround using QuickSilver. While I can’t understand why you don’t like […]

  42. Max

    Hello Mark,

    Thanks for this great post. There is also a tool called BetterTouchTool that allows you to add a keyboard shortcut for the Login Window in a snap! Check it out. It’s very cool.


  43. Mark Wheadon

    BetterTouchTool is a good tool — I use it to give me proper, nuanced mouse acceleration (oddly, something that Windows has always done well and MacOS badly).

Leave a Reply