Skip to Content
Sindre Sorhus
Back to Actions

Updated

How to Check if the Screen Is Locked in Shortcuts on Mac

By Sindre Sorhus, who makes the Actions app

With Actions

  1. Install Actions, and open it once.
  2. In your shortcut, add the “Is Screen Locked” action of Actions. It has no options.
  3. Add an “If” action below it that checks if the result is true.
  4. Put the actions for when the Mac is locked in the “If” part, and the other actions in the “Otherwise” part.

For example, a shortcut that you run on your Mac from your iPhone can stop when you are at the Mac, or show a notification only when the screen is not locked.

Tips

  • The action is for Mac. It does not work on iPhone.
  • To check if the screen saver is on, use “Is Screen Saver Active”.

Get Actions

Additional actions for the Shortcuts app

Download on the App Store

Free

Requires
macOS, iOS, or visionOS 26 or later
Updated
June 2026
US App Store rating
4.8/5 (703 ratings)

More about Actions

Without an app

The “Lock Screen” action of Shortcuts locks the Mac, but it does not tell you the state. The “Run Shell Script” action can check it with this command, which gives 1 when the screen is locked and 0 when it is not:

Shell
ioreg -n Root -d1 -a | grep -c CGSSessionScreenIsLocked || true

A script needs “Allow Running Scripts”: choose “Shortcuts › Settings”, click “Advanced”, and turn it on. The action of Actions is easier, and it gives a true or false value for “If”.