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.
lockalso works.loginWindow: does the same as
lockScreen.sleepDisplay: turns the display off. wakeDisplay: wakes it.
startScreenSaver: starts the screen saver.
screensaveralso works. stopScreenSaver stops it, and does nothing if it is not running.ejectTray: opens the disc tray of an external drive.
ejectalso works.
The step has no output. Its note names what it did, such as "Lock the screen".
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
action | text | What to do: sleep, restart, shutdown, logOut, lockScreen, loginWindow, sleepDisplay, wakeDisplay, startScreenSaver, stopScreenSaver or ejectTray. Required. An unknown value fails and lists the valid ones. | ||
op | text | Another 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
- Show “Screen saver stopped”
Gotchas #
sleep,sleepDisplay,wakeDisplay,startScreenSaver,stopScreenSaverandejectTrayrun system tools.restart,shutdownandlogOutare sent to the login window.lockScreensends ⌃⌘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.
ejectTrayfails when there is no drive that can open a tray.In a dry run the step is simulated and nothing happens.