Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MacOSX hotkey for locking screen by starting screensaver

You can usually lock the screen by hitting ctrl-shift-power, but that will power down external monitors, which might take several boring seconds to start up again. Also, a MacBook with a TouchBar doesn't have the power button anymore. With the following guide you can lock the screen by starting the screensaver, keeping the monitors running.


Set System Preferences » Security & Privacy » General » Require password immediately after sleep...

The simple way

  1. Download and unzip it to $HOME/Library/Services/

    (If you use OSX Sierra or older, use instead)

  2. Go to System Preferences » Keyboard » Shortcuts » Services » General » enable-screensaver.

  3. Choose a hotkey for it (I use ctrl-alt-cmd-k). You're good to go!

The difficult way

  • Start Automator, choose File » New and Service

  • Select that the Service receives no input in any application

  • Double click Library » Utilities » Run Shell Script

  • In the shell text field, add /System/Library/CoreServices/ > /dev/null 2>&1 &

    (If you use OSX Sierra or older, use /System/Library/Frameworks/ScreenSaver.framework/Resources/ instead)

  • Save the Service as enable-screensaver

  • Perform steps 2. and 3. above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.