31
6
On Windows I can hit Windows + L to lock my desktop. On Leopard there doesn't seem to be this capability. While I can set the screensaver to come on very quickly, I would like to hit a key combo to lock my computer.
31
6
On Windows I can hit Windows + L to lock my desktop. On Leopard there doesn't seem to be this capability. While I can set the screensaver to come on very quickly, I would like to hit a key combo to lock my computer.
2
Modern update for posterity, no additional software is required to do this. It's built-in in a number of ways.
There's a default global shortcut as a modifier of the typical "quit" shortcut to perform this action, visible against the Apple menu item Lock Screen: ⌃⌘Q (Control Command q)
Pressing this keyboard shortcut combination or selecting this entry from the Apple menu will instantly lock your display.
Menu-based actions can be remapped by the user under Keyboard System Preferences, Shortcuts tab. Use the App Shortcuts section, click the +
button, define a new keyboard shortcut, and use the Menu Title of Lock Screen
. In this way you can add or change shortcuts for any menu-accessible action in any application. An example: I have ⌘K (Command k) mapped in iTunes to the Subscribe to podcast… menu item, to match Finder's Connect to server… shortcut.
To automatically lock your display after a period of inactivity when the screensaver becomes active, configure that under Security & Privacy System Preferences. It's often convenient to not set this to Immediate to account for accidental screensaver activations, e.g. if reading a particularly dense textbook errata online or accidentally activating a "hot corner".
To make this directly usable as an action, you can utilize the ⌃⇧⏏ (Control Shift Eject) shortcut, or configure a "hot corner" to immediately trigger the screensaver under Desktop & Screen Saver System Preferences. This will allow you to "throw" your mouse into a corner of the screen as the shortcut. (This is a nod to a classic feature, dating back to one of the original screensavers on the original 1984 Macintosh: After Dark, and before that, an analog clock screensaver and a black and white fireworks demo. Upper right to activate, lower right to prevent.)
Touch Bar equipped MacBook Pro notebook computers can be configured to provide a "Lock Screen" button in the right-hand "control strip" (amusingly, this name also dates back to Classic Mac OS 8 or 9…) by using The "Customize Touch Bar…" action under Keyboard System Preferences.
Drag the Screen Lock action into the control strip portion of the Touch Bar.
Keychain Access used to offer an option to display a lock icon in the menu bar, next to the clock. This would give you access to locking the display as well as explicitly locking your keychains (forgetting your saved account password in-memory). Apple appear to have removed this feature.
This is a creative way to trigger essentially the same effect as "locking" your screen, tackled from an entirely different direction. If you enable "Fast User Switching" you can gain access to the login screen without actually logging out entirely. The option can be enabled from the Users & Groups System Preference panel, Login Options, check the checkbox.
To make this accessible by keyboard shortcut will require some extra work. For step by step instructions to accomplish this (using Automator and a command-line invocation within), please see this other Superuser answer.
A use case Apple have not covered, yet, is automatic locking based on physical proximity. They have unlocking down pat with the Allow your Apple Watch to unlock your Mac option, which is excellent, if you happen to have one of those devices. The reverse is desperately needed, though! (At some companies, leaving your workstation unlocked is a firing offence!)
Luckily, there are solutions available, though they range wildly in effective difficulty level to implement and use. I'm a true UNIX geek, and appreciate power and flexibility first and foremost, so I'm a fan of solutions like Proximity combined with Apple Script / Automator. There are also solutions like Keycard (App Store link), but that particular choice also introduces additional insecurity: "PIN unlock" as a fallback mechanism, instead of your actual system password and standard password entry screen. A helpful guide to both approaches is available.
The most consumer-friendly, though not free, option I have found so far is Unlox. It additionally supports Bluetooth Low-Energy (BTLE) by using a companion app on the device itself. (A requirement to utilize this more power-efficient technique.)
28
You can create different methods to quickly lock your screen on OS X. There is a comprehensive article here: http://www.macworld.com/article/49080/2006/01/lockscreen.html
One simple way is to:
Open Keychain Access -> preferences -> tick Show Status in Menu Bar
When you click the little Lock icon in your status bar the first entry is Lock Screen. You should be able to bind a hotkey to this in System preferences -> Keyboard shortcuts.
15
Control-shift-eject will blank the screen. If you wait until.. mmm.. sometime later this year... you may find that it also locks the screen...
You're saying it will (and already does) for sure or you hope it will? – jtbandes – 2009-07-23T18:58:51.643
1I suspect he means that in Snow Leopard this feature is there. – Matthew Schinckel – 2009-07-28T14:22:39.330
In Leopard, this doesn't lock the screen. And it's a year later! – Stefan Lasiewski – 2010-06-17T21:04:25.810
1Apparently, this can be combined with the option "System Preferences - Security - Require password immediately after sleep or screen saver begins", @Stefan. – Arjan – 2010-11-29T12:01:35.130
1This works perfectly in Snow Leopard, when “Require password immediately…” is set. – s4y – 2011-06-30T22:50:50.680
-1 Control-Shift-Eject doesn't do anything for me (Snow Leopard). – hanleyp – 2009-09-20T23:40:12.790
10
Snow Leopard provides a way to perform a Fast User Switching Lock Screen command from the keyboard using:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
This is all documented in this Art Of Geek article.
It seems the Art of Geek website is gone? More details about the same solution in Fast User Switching/Apple Menu?
– Arjan – 2010-11-06T09:45:34.203+1 This is a nice way of doing it; I just tried that it works. I hadn't used Automator before, but the article you link to explains it all very clearly. Also, if you really want to launch the screensaver instead of the user switching thing (as in the original question), check out this comment: http://artofgeek.com/2009/09/08/lock-your-macs-screen-like-in-windows-snow-leopard-edition/comment-page-1/#comment-23492
– Jonik – 2009-09-26T10:17:56.213I finally went with hotkeys for two distinct actions: Lock Computer and Lock Computer & Sleep. (Read the comments on the article to see how to achieve the latter.) – Jonik – 2009-09-26T10:32:37.617
I've been using this method since I posted this answer. It still works great. My only compliant is that it takes up to 10s to switch to the Login Window. – hanleyp – 2009-09-27T16:08:16.930
Calling the command line from terminal takes about 8s, so 2s is the Automator activating and 8s is the actual CGSession call. – hanleyp – 2009-09-27T16:09:55.087
8
The easiest way, once it is set up, allows you to move the mouse to a corner of the screen, the screen saver activates immediately and requires a password to dismiss the screen saver.
Set up a "Hot Corner" to activate the screen saver. This is in the "System Preferences", "Desktop & Screen Saver" pane. There is a button for "Hot Corners..." in the "Screen Saver" tab.
Go to the "Security" preference pane. Make sure the checkbox for "Require password to wake this computer from sleep or screen saver." is checked.
5
Here is an easy implementation:
At this point all you have to do is click on the little keylock icon and select "Lock Screen", but here is something extra for more fun:
(It doesn't hurt to test it now by pressing the "Play" button)
(Test some more)
Now comes the real "magic"
If you tested and followed this carefully, pressing the shortcut above will load the Service you created in Automator which in turn runs the workflow which moves the mouse to the Keychain menu and locks the screen for you.
Keychain Access menubar accessory has been removed for at least the last two major versions of macOS (not present in 10.14, nor 10.13). Alternative to this is the "Fast User Switching" process, with similar need to utilize an Automator workflow to expose the command-line invocation as a menu item, which can be assigned a keyboard shortcut via Keyboard System Preferences. On modern versions: ⌃⌘Q and you're done. – GothAlice – 2019-06-20T14:56:41.263
4
Edit security settings to require a password to wake up from screen saver, throw this line into an apple script:
tell application id "com.apple.ScreenSaver.Engine" to launch
If you have quicksilver you can then setup a trigger to launch the applescript using whatever keystroke you like. Or you can add it as an application specific script ~/library/application support/"application name"/scripts and then use the built in MAC keyboard shortcuts to launch the script via that applications menu items.
4
Configure screen saver password and press Shift + control + eject
1
Option 1: Enable the fast user switching menu in the Users & Groups preference pane, and select Login Window… from the menu.
Option 2: /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
Option 3: Many launchers and macro utilities also include a command for logging out to the fast user switching screen.
Option 1: Enable the Keychain menu extra in the preferences of Keychain Access and select Lock Screen from the menu.
Option 2: Check Require password immediately after sleep or screen saver begins in the Security & Privacy preference pane. You can then lock the computer manually by pressing ⌃⇧⏏ to turn off the display or ⌥⌘⏏ to go to sleep.
1
Below is a tweak on Alejandrormz's Automator steps. This is in OSX Mavericks:
Optionally:
-3
You can log off immediately by typing
⌘ ⇧ ⌥ Q
Your screensaver should kick in automatically after a while.
Update: The above is the easy Mac way. As usual, anything else Apple doesn't want you to do easily involves lots of pain.
You can almost hear Steve sneering, "Lock Screen with a keyboard is soooo Windows. Use a mouse people."
Jokes aside, Mark Wheadon has an extensive article documenting various methods. It turns out Apple really doesn't want you to use the keyboard to accomplish a Lock Screen...easily. Bad Apple. ;-)
1log off first don't sound similar to locking the desktop – Joakim Elofsson – 2009-07-23T16:58:39.560
1But the question asked "is there a keystroke" to do it. The answer would be, no, not officially. But if you're willing to suffer then yes, there is a keystroke. In that case darren_n's method would be better. – GeneQ – 2009-07-23T17:34:07.183
10 years later, this is hilariously off-the-mark. ⌃⌘Q, and as has been the case since NextSTEP, customization of the shortcut via Keyboard System Preferences. – GothAlice – 2019-06-18T15:23:57.763
This logs you off, downvoted. – HaggleLad – 2012-12-24T14:12:07.013
1This is the best way I've found without using a third party app. – dulaneyb – 2009-07-23T17:10:18.223
+1 this is how I do it - Keychain access icon on the menu – robsoft – 2009-07-23T17:36:25.493
Good way to do it. – GeneQ – 2009-07-23T17:44:55.003
Apple removed this option from Keychain Utility, added an actual shortcut: ⌃⌘Q (@Rabarberski) – GothAlice – 2019-06-20T15:11:35.653
Very lousy that there is no native shortcut for this :-( – Rabarberski – 2012-02-06T11:14:23.030
Can you elaborate with some "for dummies" advice regarding setting the hotkey? I added an "application shortcut" where application is Keychain Access.app and menu title is "Lock Screen", but it won't work. – Jonik – 2009-09-26T10:05:18.377