Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A small shell script that can be used on macOS to change the sound volume from the Terminal. Requires bc (should be built-in on macOS).
if [ -z "$1" -o "$1" -lt 0 -o "$1" -gt 100 ]; then
echo "Usage: $0 new_volume" >/dev/stderr
echo " new_volume must be between 0 and 100" >/dev/stderr
exit 1
new_volume="$(echo "($1 * 8) / 100" | bc)"
osascript -e "tell application \"System Events\" to set volume $new_volume"; # Max is 8, min is 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.