Screen Wake Password Entry Macro Or Avoid Screen Lock When Connected To Specific Wifi Macro Help

I have my MacBook Pro set to never go to sleep. However, the display will sleep after 15 minutes. I want to only lock the screen when away from (not connected to) my home wifi network or automatically enter the password to unlock the screen (on screen wake) when connected to my home wifi. Can someone demonstrate how KM would be used to automatically enter the password when the MacBook Pro wakes or only lock the screen when disconnected from the home wifi network?

I do not believe it is possible for Keyboard Maestro to type in the password when the screen is locked.

When the screen is locked or screen sharing, UI control is disabled.

For changing the auto-screen-lock setting you have to enter your login password, AFAIK.

Peter & Tom,

Thanks for responding!

The following shell script was recommended for Sierra, but doesn't seem to work. Are either of you able to successfully disable the password requirement using it?

do shell script "/usr/bin/defaults write com.apple.screensaver askForPassword -int 0"

Do either of you see anything wrong with the test macro I'm attempting or can you recommend an alternative approach?

Keyboard Maestro “Set Screen Lock/Unlock Requirement Macro” Macro

Set Screen Lock-Unlock Requirement Macro.kmmacros (8.1 KB)

It seems that this changes the preferences, but it has no effect. Probably you have to restart or logout/login to see the effect, I haven’t tried it.

If you could change the setting without entering your credentials it would defeat the security purpose of that setting.

An alternative approach?

  1. Set the Security Preferences to not ask for a password when the display sleeps.
  2. When you’re not at home make it a habit to suspend the session when you’re moving away from the computer.

At least three ways to do this:

  • The fast user switching menu bar item (can be activated in Users & Groups)
  • Via Terminal: /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
  • Via KM action “Login Window”

You could also combine the latter with a Wake trigger and a Wireless Network condition in KM.