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…?
3 Answers
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.
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
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…