Q: Increase / Decrease iTunes Volume Using Terminal Command Via Automator
Hi there,
I'm new to terminal but I would like to set up two separate Automator actions to control the volume in iTunes (not the system audio): one to increase and one to decrease, possibly over 10 seconds and perhaps with the ability to adjust if necessary.
Note: I'm fine with setting up the Automator actions etc.. and I don't won't to run it from an applescript as there are other automator actions the need to happen after the increase/decrease in volume. I think if I ran it from an applescript, Automator would set the script running and then continue without waiting for the outcome (I may be wrong on this).. but I also think running it all within Terminal would be tidier.
I've done some digging around the net and apple forums.. this is what I've found:
I think its a osascript command, like these:
osascript -e 'tell application "iTunes" to play'
osascript -e 'tell application "iTunes" to pause'
This works for the system audio:
for((i=0;i<50;i++)); do
osascript -e "set volume output volume $i"
done
This is an applescript that works, but I couldn't figure out how get it to run over 10 seconds.. I timed it and it seemed to take about 1min 20ses.. although it says two mins and I don't really want to use an applescript. Using Automator to gradually increase volume
Any help or suggestions would be greatly appreciated
Posted on Oct 6, 2015 1:00 PM
I think you're a little misguided on the details and differences between terminal scripting and AppleScript.
Your terminal script:
osascript -e "set volume output volume $i"
IS AppleScript - 'osascript' is the terminal/shell command to invoke AppleScript.
So what you're asking for is an Automator action to fire off a Terminal/shell script to invoke an AppleScript...?
Why not cut out the middleman and go straight to the AppleScript?
My suggestion, create an Automator workflow with a 'Run AppleScript action that contains the following:
tell application "iTunes"
play
repeat with i from 1 to 100
set sound volume to i
delay 0.2
end repeat
end tell
This will start playing your music and increase the sound level from 1 to 100 over 20 seconds (thanks to the 0.2 second delay between increments)
Posted on Oct 6, 2015 1:34 PM