Reset volume control to 80% before shutdown
I sometimes reduce the volume on my El Capitan while working. I would like to ensure that it returns to, say, 80% before shutdown, in case I forget to do it myself. Any solutions would be most welcome BUT remember I'm a beginner with this stuff!
Solution 1:
I have generated a script to run this for you. I have just tested it out on a computer running sierra, but it should be fine with your system. It consists of three files. All of these can be compiled using the setup script available for direct download from Github. When you download, just open it, and press the play button ► located at the top corner of the program.
Edit: I realized it is not downloading the files. Be sure to right click the Setup Download and save link as...
Setup Download
do shell script "sudo curl -O -L https://raw.githubusercontent.com/brettpetch/setvol-onshutdown/master/setvol.sh" with administrator privileges
do shell script "mv setvol.sh ~/Downloads/setvol.sh" with administrator privileges
do shell script "curl -O -L https://raw.githubusercontent.com/brettpetch/setvol-onshutdown/master/com.brettpetch.setvol.plist" with administrator privileges
do shell script "sudo mv com.brettpetch.setvol.plist /Library/LaunchDaemons/com.brettpetch.setvol.plist" with administrator privileges
do shell script "sudo launchctl load /Library/LaunchDaemons/com.brettpetch.setvol.plist" with administrator privileges
setvol.sh Download
#!/bin/bash
# setvol.sh
#
#
# Created by Brett Petch on 2017-07-31.
#
function shutdown()
{
#add additional commands to run at shutdown
sudo osascript -e "set Volume 8"
}
function startup()
{
tail -f /dev/null &
wait $!
}
trap shutdown SIGTERM
trap shutdown SIGKILL
startup;
Next, I created a PLIST for the LaunchDaemons.
com.brettpetch.setvol.plist Download
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>boot.shutdown.script.setvol</string>
<key>ProgramArguements</key>
<array>
<string>~/Downloads/setvol.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>~/Library/Logs/setvol.log</string>
<key>StamdardErrorPath</key>
<string>~/Library/Logs/setvol.err</string>
</dict>
</plist>
Then create something so people can get it easily; I used script editor and wrote a bit of AppleScript.