Set/get OSX volume/mute from the command line
I ended up wanting to do this when wrapping the OSX `say' command. I have a wrapper script on github which sets the volume and unmutes, runs the say command, restores the volume level and mutes again if appropriate.
Get volume
# Echos a number from 0 to 100
osascript -e 'output volume of (get volume settings)'
Set volume
# Where 50 is a number from 0 to 100
osascript -e 'set volume output volume 50'
Get mute state
# Echos a string of 'true' or 'false'
osascript -e 'output muted of (get volume settings)'
Set mute state
# Where 'true' can be 'true' or 'false'
osascript -e 'set volume output muted true'
Written by Nicholas Robinson-Wall
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#