Guide How to lock your Mac OS X
(This will not shutdown your computer or put it in sleep mode)
Step 1
Go to Applications > Select Automator -> Select Service template and click Choose
Scroll down or type in search bar to find Run shell script. Drag it to right where it says Drag actions or files here to build your workflow
Now it will look something like this. Select the drop-down in front of Service receives selected and select No input.
Now in the text box you can see cat written. Select cat and paste the following in its place:
exec /System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
Select File from the menu bar and click save. Give it a name e.g. Lock Mac.
Now exit Automator.
Step 2
Go to system preference and select Keyboard and then Keyboard shortcuts
Select Services from the menu on the left side and then scroll down to General in the menu on the right side. You will find your service Lock Mac without any shortcut. Select a shortcut of your liking and youre done. Remember to select a shortcut that isnt already being used. (This is tricky but youll get the hang of it)
(This will not shutdown your computer or put it in sleep mode)
Step 1
Go to Applications > Select Automator -> Select Service template and click Choose

Scroll down or type in search bar to find Run shell script. Drag it to right where it says Drag actions or files here to build your workflow

Now it will look something like this. Select the drop-down in front of Service receives selected and select No input.

Now in the text box you can see cat written. Select cat and paste the following in its place:
exec /System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
Select File from the menu bar and click save. Give it a name e.g. Lock Mac.
Now exit Automator.
Step 2
Go to system preference and select Keyboard and then Keyboard shortcuts

Select Services from the menu on the left side and then scroll down to General in the menu on the right side. You will find your service Lock Mac without any shortcut. Select a shortcut of your liking and youre done. Remember to select a shortcut that isnt already being used. (This is tricky but youll get the hang of it)