Skip to content

Instantly share code, notes, and snippets.

@Akira-Hayasaka
Created April 5, 2015 00:39
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akira-Hayasaka/026b7c7ae611bc7485e4 to your computer and use it in GitHub Desktop.
Save Akira-Hayasaka/026b7c7ae611bc7485e4 to your computer and use it in GitHub Desktop.
osx shutdown, restart, sleep script
Shut down without showing a confirmation dialog:
osascript -e 'tell app "System Events" to shut down'
Shut down after showing a confirmation dialog:
osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
Restart without showing a confirmation dialog:
osascript -e 'tell app "System Events" to restart'
Restart after showing a confirmation dialog:
osascript -e 'tell app "loginwindow" to «event aevtrrst»'
Log out without showing a confirmation dialog:
osascript -e 'tell app "System Events" to «event aevtrlgo»'
Log out after showing a confirmation dialog:
osascript -e 'tell app "System Events" to log out'
Go to sleep (pmset):
pmset sleepnow
Go to sleep (AppleScript):
osascript -e 'tell app "System Events" to sleep'
Put displays to sleep (10.9 and later):
pmset displaysleepnow
https://developer.apple.com/library/mac/qa/qa1134/_index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment