Shutting down the macbook command
-
What command do I use to turn off my macbook via triggercmd? I have already tested several including the windows and cmd commands with "sudo" in the trigger and nothing works, could someone help me?
-
@Ivan-Freitas, these commands shutdown a mac in 60 seconds, or now (immediately):
sudo shutdown -h +60 sudo shutdown -h now
While testing this, you can run the +60 command and be ready to run this command to cancel the shutdown:
sudo killall shutdown
To use the shutdown command with TRIGGERcmd, you'll need to allow it to run without a password prompt. To do that, add this line to your sudoers file:
ALL ALL=(ALL) NOPASSWD: /sbin/shutdown
You can edit your sudoers file with visudo or nano. To use nano, you'll need to switch to the root user first with sudo su -, then run nano /etc/sudoers
EDIT: I stand corrected. See @Ulisses-Honor's solution below. That's much simpler.
-
@Russ said in Shutting down the macbook command:
sudoers
I tried to do this configuration, but as I don't understand enough, I don't know how to configure this sudoers
-
@Ivan-Freitas, this video might help: https://youtu.be/cbjNMyqM4rE?t=44
It shows how to open the sudoers file with the visudo command. Once you've opened it, press the i button to go into edit mode, and press the ESC button to exit edit mode after you've added that line. Then type :wq, and press enter to save and exit.
EDIT: Nevermind. To shutdown you can use @Ulisses-Honor's osascript command below.
-
@Ivan-Freitas ```
osascript -e 'tell app "System Events" to shut down' -
@Ulisses-Honor It's really worked for me, just copy and paste on Gui Command Editor.
-
Hi guys, here's a script I set up to simulate the standard Mac shutdown. I hope you like it!
osascript -e 'tell application "System Events" to click menu item "Shutdown…" of menu 1 of menu bar item "Apple" of menu bar 1 of process "Finder"'