Is there a way for locking the screen and putting it to sleep/activating the screen saver to be two different events on a MBP?

This question is very similar to what I want to accomplish, except for the fact that I also want to be able to put the display to sleep at times without triggering it to ask me for a password. I basically want to be able to do two things:

  • At times, lock the screen, much like I do in a PC by hitting Win+L. I'm fine with the screen going to sleep at this time, and if this step was all I wanted, hitting control+shift+power would do the trick if Require password [amount of time] after sleep or screen saver begins under System Preferences > Security was checked. However;
  • I also want to be able to, sometimes, just put the display to sleep or let it eventually start the screen saver without it asking for a password afterwards. I could also accomplish this one simply, if I unchecked Require password [amount of time] after sleep or screen saver begins under System Preferences > Security, but again that would make me unable to do what I wanted to do above.

I can do this all in Windows by enabling the screen saver, and not checking the box that specifies that it'd get me to the login screen when on resume. That way, I can let the screen saver get triggered and the display eventually go to sleep and it won't ask me for a password when I resume; and I can also simply lock the session when I want to by hitting Win+L, and then the display will eventually go to sleep.

Is this possible to accomplish in a Mac?


Solution 1:

There are a number of posts (here and here) on superuser.sx.

  • To lock the screen (actually invoking the "Login Window…" action from the User menu, and a direct analog to the Win+L shortcut in Windows):

    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
    
  • To sleep the display (I use this all the time as part of my last command before bedtime on my home machine):

    pmset displaysleepnow
    

Either of these options can be invoked through a keyboard shortcut by tying a shell script to a shortcut (using Automator (like this), Quicksilver, LaunchBar, Alfred, etc., see this post).

It's worth noting that BetterTouchTool can also perform these actions (directly mapping shortcuts to actions like this), as noted in this answer to one of the prior questions). The developer has been giving the app some love recently, which has been wonderful to see.

Solution 2:

here is a solution, with mouse movements (not keyboard shortcuts).

FOR THE FIRST PART

Go to user & groups

users groups

Enable fast switching.

enter image description here Whenever you need to activate the login screen click login screen on top right. It will need the login password to open again.

enter image description here

(If you still need to define keyboard shortcut, please look this link, though I didn't test it, but it might probably work.

http://www.macyourself.com/2013/01/27/how-to-lock-your-mac-screen-with-a-keyboard-shortcut/ )


FOR THE SECOND PART

Disable "require password" option security & privacy section.

1- In system preferences, select Mission Control,

select mission control

2- Then click on hot corners on lower left

click on hot corners

3- From there define your actions by assigning actions to each screen of your mac

hot corners of screen

4- Here are the standard actions of mac, when you move your mouse to those corners of screen

actions defined

And next time when you move your mouse, your screen saver will be activated.