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…?
Asked
Active
Viewed 2,275 times
7
-
Bring the dialog from terminal? – Martin Marconcini Oct 03 '13 at 03:07
-
See http://hintsforums.macworld.com/archive/index.php/t-103777.html. – lhf Oct 03 '13 at 03:18
3 Answers
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.
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…
Martin Marconcini
- 21,864