Although OS X has many useful features and goodies, I personally miss one very important one - a keyboard shortcut for locking the Mac (something like Windows-L on Windows). If you have a username or stick icon displayed in the menu bar, you can lock your Mac from this menu. But what if you have little space in the bar or prefer a keyboard shortcut? You can use one of the third-party applications or create a shortcut yourself using our instructions.
Start Automator
1. Create a new file and select Service
2. In the left column, select Utility and in the column next to it, double-click on Run Shell Script
3. In the script code, copy:
/System/Library/CoreServices/“Menu Extras”/User.menu/Contents/Resources/CGSession -suspend
4. In the script options, select Service does not accept no input ve all applications
5. Save the file under any name you like, eg "Lock Mac"
Open System Preferences
6. Go to Keyboard
7. In the tab Abbreviations select from the left list Services
8. In the right list you will find under In general your script
9. Click on add a shortcut and choose the desired shortcut, e.g. ctrl-alt-cmd-L
If you choose an inappropriate shortcut, the system will sound an error sound after entering it. If another application is already using the shortcut, it will take precedence and the Mac will not lock up. The instructions may seem quite "geeky", but everyone should be able to follow them. We hope that this guide will make your daily work more pleasant and faster.
Addition to the article:
We have inadvertently confused some of you with this guide and I would like to shed some light on the confusion. The article is really only intended for locking the Mac and needs to be distinguished from turning off the display and putting the Mac to sleep.
- Lockdown (no native shortcut) – the user just locks their Mac, but the applications remain active. For example, you can export a long video, lock your Mac, walk away and let it do its job.
- Turn off the display (ctrl-shift-eject) – the user turns off the display and that's all that happens. However, it may happen that the system preferences require a password when the display is turned on. In this case, the login screen will appear, but this is another functionality related to turning off the display, not locking the Mac as such.
- Sleep (cmd-alt-eject) – the user puts the Mac to sleep, which of course stops all computer activity. It is therefore not a lock, even if the user may again have set password enforcement after waking up in the system preferences.
- Logout (shift-cmd-Q) – the user is completely logged out and redirected to the login screen. All applications will be closed.
I use the system shortcut Cmd (⌘) + Alt + Eject Media (⏏) to sleep, which also locks the Mac...
Where is the "Eject media (⏏) to sleep" button please
I have it above "backspace" - see picture http://img2.czc.cz/8ead0qjmu0i229kldvvnnta8c1_7/obrazek
on newer ones (without a drive) it's Alt + cmd + shutdown button
Maybe it's new for you, but this keyboard shortcut is native in the system ;-) Ctrl+Shift+Esc
It's not, but this is a shortcut for turning off the display ;-) The fact that someone gets a login screen after turning it on depends on the system settings and is not a lock.
It's true, I have it set up like this, and thus there is no need to set up my own keyboard shortcuts...
Well, I see it the same as my colleague Tomas. Why take a long time to do something in the automaton, when I just check enter the password after turning on the display and I have the keyboard shortcut there natively. I lock my Mac because I'm going away, won't be using it for a long time, not because I lock it and then look at the lock screen.
So, for me, the instruction does not make sense, but I believe that it will be useful to someone :-)
Yes, just put the Mac to sleep and it asks me for the password. It also works if you use Active Edges to put the screen to sleep (eg move the cursor to the lower left corner to put the Mac to sleep if you so choose). When you press any key, the Mac then asks for a password…
I will answer the same as the comment below. I don't want to put my Mac to sleep because I have something running on it, just lock it.
Would it be able to turn off the display on the MAC when I'm watching a movie via cable on the TV? I always have to set the backlight to a minimum.
However, it is only about putting the display to sleep, not putting the Mac to sleep :)
Good tip!
Good tip! No irony.
I confess that I use "Hot Corners". Preferences -> Destkop & Screen Savers -> Screen Saver Hot Corners button and I have set CMD + upper right corner as "Put display to sleep", it should be noted that for this it is necessary to set the computer to ask for a password when returning from this mode. I've had it since 2008 and I still like it better than a keyboard shortcut, but we're all different :-)
I use the native shortcut to turn off the display ctrl + shift + eject (⏏) (on newer power) and wake up with a password
Well, in order to press the hafol keys for such a banal ending, I must have laboriously created the given function. Well, it's funny.:-) I had fun....
We are glad that you also enjoy our humor-free tutorials :)
I have to thank the author. I've been looking for something similar in the past... since I have my Mac set so that it doesn't lock when I put it to sleep, but sometimes when I leave the Mac for a long time I need to lock it so that the processes continue to run in the background.
Maybe this guide is not suitable for everyone, but you don't have to criticize it for that. ;) Whoever the article helps, is grateful for it, and if someone doesn't, just ignore it.
So once again a big DIK for me.
Nice tip, nice article, thanks a lot :) Just a note, the tutorial doesn't work on my MBP Retina 2012 late with Yosemite. When choosing a hotkey group, I had to choose application shortcuts and not services. :)
PS: The article doesn't seem geeky to me, but maybe that's because I switched to an apple computer from a linux pécécque. :D
It bothers me to set the password after the display turns off, because at home it's almost like entering the password X times a day. Automator is useless. The easiest way is to let its icon appear in the menu bar in the Keychain application settings - then the lock icon will be there. In the menu there you can select Lock screen and the screen will turn off. Next, a password is requested. Simple, functional, I only use it if I really want to lock the Mac.