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

Updated: November 24, 2026

- [Actions](https://sindresorhus.com/actions.md): Additional actions for the Shortcuts app. Price: Free. Platforms: macOS, iOS, visionOS. Get it from: [App Store](https://apps.apple.com/app/id1586435171). Requires macOS, iOS, or visionOS 26 or later. Size: 13 MB on Mac, 29 MB on iPhone and iPad. Free older versions for macOS 15, 14, 13, and 12: [download](https://sindresorhus.com/actions#older-versions). US App Store rating: 4.8/5 (703 ratings).

URL: https://sindresorhus.com/guides/shortcuts-check-screen-locked-mac

Add the “Is Screen Locked” action of the free [Actions](https://sindresorhus.com/actions.md) app, and check its result in an “If” action. [Without an app](https://sindresorhus.com/guides/shortcuts-check-screen-locked-mac#without-an-app), a “Run Shell Script” action with a command can check it.

## With Actions

1. Install [Actions](https://sindresorhus.com/actions.md), and open it once.
1. In your shortcut, add the [“Is Screen Locked”](https://sindresorhus.com/actions#:~:text=Is%20Screen%20Locked) action of Actions. It has no options.
1. Add an “If” action below it that checks if the result is true.
1. 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](https://sindresorhus.com/guides/run-mac-shortcut-from-iphone.md) can stop when you are at the Mac, or show a notification only when the screen is not locked.

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

## 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:

```sh
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”.
