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.

macOSmacosdefaultsprivacysecurityMedium risk
Run `defaults write com.apple.screensaver askForPassword -int 1 && defaults write com.apple.screensaver askForPasswordDelay -int 0`.

01Command

Command
$ defaults write com.apple.screensaver askForPassword -int 1 && defaults write com.apple.screensaver askForPasswordDelay -int 0

02What 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

RiskMedium risk
!Warning: With a zero delay, unlocking instantly after every brief screen blank can get annoying on desktops you use alone.

04Undo

Undo
$ defaults delete com.apple.screensaver askForPassword && defaults delete com.apple.screensaver askForPasswordDelay

05Sources

  • macOS defaults - read, write and delete macOS user defaults
    SS64 · technical · 2026-09-17
    Evidence: 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)
    mathiasbynens/dotfiles (GitHub) · community · 2026-09-17
    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