Last active
September 7, 2017 12:42
-
-
Save Frizlab/5562830 to your computer and use it in GitHub Desktop.
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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 | |
fi | |
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