Browse the docs

Sleep, restart or log out

Sleeps, restarts, shuts down, logs out, locks the screen, or controls the display, screen saver and disc tray.

action the Mac

Keyboard Maestro: SystemAction Sleep, SystemAction Restart, SystemAction Shutdown, SystemAction LogOut, SystemAction LoginWindow, SystemAction SleepDisplay, SystemAction WakeDisplay, SystemAction ActivateScreenSaver, SystemAction StopScreenSaver, SystemAction OpenCloseCDROM, FastUserSwitch

Details #

Does one power or display action, chosen by action (op is another spelling). The name is matched ignoring case and punctuation.

  • sleep: puts the Mac to sleep.

  • restart, shutdown, logOut: do that right away, with no confirmation.

  • lockScreen: locks the screen. lock also works.

  • loginWindow: does the same as lockScreen.

  • sleepDisplay: turns the display off. wakeDisplay: wakes it.

  • startScreenSaver: starts the screen saver. screensaver also works. stopScreenSaver stops it, and does nothing if it is not running.

  • ejectTray: opens the disc tray of an external drive. eject also works.

The step has no output. Its note names what it did, such as "Lock the screen".

Parameters #

ParameterTypeRequiredValuesWhat it does
actiontextWhat to do: sleep, restart, shutdown, logOut, lockScreen, loginWindow, sleepDisplay, wakeDisplay, startScreenSaver, stopScreenSaver or ejectTray. Required. An unknown value fails and lists the valid ones.
optextAnother spelling of action.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Stop the screen saver. This is harmless when none is running, and it really stops one if it is:

Stop the screen saver (harmless if none is running)
Do
  1. Stop the screen saver
  2. Show “Screen saver stopped”
Open in Switchboard to try it

Gotchas #

  • sleep, sleepDisplay, wakeDisplay, startScreenSaver, stopScreenSaver and ejectTray run system tools. restart, shutdown and logOut are sent to the login window. lockScreen sends ⌃⌘Q through System Events.

  • The actions that use System Events or the login window need Automation permission. If it is missing, the step fails with a message pointing to System Settings > Privacy & Security > Automation.

  • ejectTray fails when there is no drive that can open a tray.

  • In a dry run the step is simulated and nothing happens.

See also #

Change screen brightness, Light or dark mode, Ask for input