7

I know how to shutdown a Mac from Terminal, but is there a way to actually bring up the shutdown dialog you get from Apple → Shut Down…?

grg
  • 201,078
JShoe
  • 5,139

3 Answers3

8

You can send loginwindow the kAEShowShutdownDialog Apple event:

osascript -e 'tell application "loginwindow" to «event aevtrsdn»'

The four letter codes for Apple events are listed in AERegistry.h. See this answer for more information.

Lri
  • 105,117
3

This should work:

Applescript:

-- Open  Shut Down Dialog...
-- Save this text as file named shutdown.scpt
tell application "System Events"
    set uiScript to click menu bar item "Apple" of menu bar 1 of application process "Finder"
    set uiScript to click menu item "Shut Down…" of menu 1 of menu bar item "Apple" of menu bar 1 of application process "Finder"
end tell

You can run it from Terminal like:

osascript shutdown.scpt
nohillside
  • 100,768
l'L'l
  • 9,105
0

You can create an Automator script that you can later run from the command line with "open".

You could "Record" in Automator. I guess that would be the easy way, but there might be other problems. Because when you record, Automator actually records mouse pointer movements…