Require the Login Password Immediately After Sleep or Screensaver
Set askForPassword to 1 and askForPasswordDelay to 0 so no grace period exists after the screen locks.
01Command
$ defaults write com.apple.screensaver askForPassword -int 1 && defaults write com.apple.screensaver askForPasswordDelay -int 002What it does
askForPassword controls whether leaving the screen saver or display sleep requires a password at all, and askForPasswordDelay is the grace window (in seconds) during which you can return without typing it. Setting the delay to 0 closes the window where a colleague could wake your Mac and read your mail. Note the modern UI equivalent lives in System Settings > Lock Screen; these defaults keys still work for the current user account and are handy for scripted setups.
03Risk
04Undo
$ defaults delete com.apple.screensaver askForPassword && defaults delete com.apple.screensaver askForPasswordDelay05Sources
- macOS defaults - read, write and delete macOS user defaultsEvidence: Documents `defaults write domain key -int value` for integer preference keys in per-app domains such as com.apple.screensaver, and `defaults delete` to remove overrides.
- macOS setup dotfiles (.macos)Evidence: Contains 'defaults write com.apple.screensaver askForPassword -int 1' and 'defaults write com.apple.screensaver askForPasswordDelay -int 0' with comments about requiring a password immediately after sleep or screensaver.
Last verified: 2026-09-19 · Category: Security & Privacy
06Related solutions
Point macOS screen captures at any folder you choose instead of the desktop.
Make Finder display .pdf, .docx, .png and every other extension at all times.
Permanently display the full folder path at the bottom of every Finder window.