Skip to content

About

Turn off your Mac's display the moment you lock the screen (Ctrl-Cmd-Q) — a tiny zero-dependency launchd daemon

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

DisplaySleepOnLock

Turn off your Mac's display the moment you lock the screen.

中文文档

When you press Ctrl-⌘-Q (Lock Screen), macOS locks the session but keeps the display on until the display-sleep timer expires — and the shortest interval System Settings offers is 1 minute. DisplaySleepOnLock closes that gap: a tiny background daemon listens for the system lock notification and puts the display to sleep about one second after you lock.

Features

  • Immediate — the display turns off ~1 s after locking instead of waiting out the display-sleep timer
  • Zero dependencies — one single-file Swift daemon built with the system toolchain; no Hammerspoon, no third-party apps
  • Self-managing — installed as a launchd agent that starts at login and is restarted automatically if it ever exits
  • Featherweight — ~60 KB binary, idles at 0% CPU

Requirements

  • macOS (developed and tested on macOS 27)
  • A Swift toolchain to build the binary: Xcode, or the Command Line Tools (xcode-select --install)

Install

git clone https://github.com/cunminF/DisplaySleepOnLock.git
cd DisplaySleepOnLock
./install.sh

install.sh compiles the daemon to ~/bin/DisplaySleepOnLock, writes the LaunchAgent ~/Library/LaunchAgents/local.DisplaySleepOnLock.plist, and loads it. Done — press Ctrl-⌘-Q and the display goes dark right after the lock screen appears. Move the mouse or press a key to wake and unlock as usual.

How it works

macOS broadcasts a distributed notification named com.apple.screenIsLocked whenever the screen locks. The daemon subscribes to it via DistributedNotificationCenter and, one second later (letting the lock-screen transition settle), runs pmset displaysleepnow.

Troubleshooting

Activity is logged to ~/Library/Logs/DisplaySleepOnLock.log. Each lock should produce a screenIsLocked received line followed by pmset displaysleepnow issued. If it doesn't, please open an issue with the log contents and your macOS version.

Uninstall

./uninstall.sh

License

MIT © 2026 cunminF

About

Turn off your Mac's display the moment you lock the screen (Ctrl-Cmd-Q) — a tiny zero-dependency launchd daemon

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages