1

I want to create one hotkey that puts my monitor to sleep without requiring a password to wake it, and another hotkey that puts my monitor to sleep which does require a password to wake it.

I'll be using BetterTouchTool to create the hotkeys - but how do I create one that requires a password and another that doesn't? Bonus points if I can do this using Applescript since I already have a BTT/Applescript hotkey for when I'm leaving the house which turns off my Hue lights, mutes my Mac and puts my monitor to sleep.

I realize I can go into system prefs > security & privacy and select "require password immediately after sleep or screen saver" but that would mean I'd have to enter my password every time I put my monitor to sleep, which is what I don't want.

1

The following assumes you have/use a Login password:

do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"

This can be used in AppleScript to invoke the Login window, which will not close whatever you currently have open and as such when you log back in, your Desktop is as you left it.

This way you can have the "Require password ... after sleep or screen saver begins" check box in Security & Privacy's General tab unchecked but still not let someone have immediate access after you walk away, having invoked the Login window.

  • That definitely works and I may use it if I can't find a better way. I was hoping to not have to log out, which that solution does. – 2oh1 Mar 1 '17 at 23:56
  • @2oh1, It does not log you out! It merely brings up the Login window. As an example I can start a big download from the Internet, look at my Router to see the download is occurring, run that command and the Login window appears while the Router is showing the download still continues. If it actually logged me out, it would terminate the download! Nor would the large number of apps with several dozen windows opened appear all at once instantaneously as the Login windows disappears instantaneously as well. – user3439894 Mar 2 '17 at 0:17
  • Are you sure? ...does it terminate anything? It seems like there's a difference between entering my password on the login screen vs entering my password when waking my monitor (assuming I'd licked that option in system prefs). When entering my password from the login screen, I always hear the faint whirr of my external hard drives starting up, and there's always a pause (though only a few seconds), but that doesn't happen when entering my password when waking my monitor. Regardless, login screen offers Guest access option and I don't want that for this type of situation. – 2oh1 Mar 2 '17 at 0:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .