2

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!

2 Answers 2

2

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.

0
0

You can write an AppleScript program that will change your volume and shut down your computer (you would use this instead of Apple>Shut Down). You can also make a script that runs on login if you prefer.

Useful links:

Change volume in AppleScript

Shut Down in AppleScript

(edit: someone got the script before me)

2
  • I just added the script along with a setup file.
    – bret7600
    Commented Jul 31, 2017 at 14:49
  • @bret7600 cheers, you beat me :)
    – jbwar22
    Commented Jul 31, 2017 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .