craftwa.re

A walk outside the sandbox

Home Blog Cheat Sheets MacOS Tips Area 51 About

Keyboard Combo To Lock Screen

|

Overview

In the previous tips we’ve seen how to lock the screen quickly using mouse only and Hot Horners or using the Keychain Access menu. Another quick option to do that is to assign a key combination to a script execution/ This could either be the same AppleScript we’ve seen before that clicks the Lock Screen button or a different one. For variety, let’s go for a different one.

The following very simple bash command can be used to put the display to sleep:

$ pmset displaysleepnow

To assign a global shortcut to this script I’ve used Simple hotkey daemon for macOS. Just add the following line to the config file ~/.skhdrc:

shift + cmd - l: ~/scripts/sleep.sh

You’ll now be able to use the ⇧ + ⌘ + L (Shift + CMD + Capital L) to lock the screen. So here you have 3 quick ways, there’s no reason to leave your machine unlocked anymore:

  1. Hot Horners
  2. Keychain Access
  3. Global shortcut