I normally run my Mac with a very long password delay on the screensaver. Sometimes, though, I want to reduce the delay to just 1-2 seconds.
This command is supposed to reduce the time for the delay to a second:
defaults write com.apple.screensaver askForPasswordDelay -int 1
This command makes the laptop sleep again:
pmset sleepnow
And this command activates the screen saver:
open -a /System/Library/Frameworks/ScreenSaver.framework//Versions/A/Resources/ScreenSaverEngine.app
My problem: if I run any combination of these commands when the screen saver delay is 60 minutes, the computer does not immediately ask for a password when it wakes up or the screen saver stops. I need to open the system preferences after I run these commands in order for the defaults write to get registered. And if the Preferences pane is open, it never gets registered.
I think that the Preferences pane is doing something else --- that is, I think that the information about how long to sleep or be in screen saver before a password is required is being stored someplace other than this defaults entry and the Preference pane is copying from one to another.
How do I make the Mac immediately require a screensaver password without opening the preferences pane? How do I have the password not be required for 60 minutes? How do I get MacOS to respect the dwrite
? I suppose I could kill the Preferences program and then re-open it with AppleScript, but that seems silly (and slow)