Created
April 28, 2021 20:43
-
-
Save noahcoad/b36d9bce7c498ff5cc1ad19fa15a742d to your computer and use it in GitHub Desktop.
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 | |
# 2021-04-28 by Noah Coad | |
# simple bash script to turn the Mac OSX volume up, down, get value, or set | |
# vol = get current volume level | |
# vol u = volume up by 5% | |
# vol d = volume down by 5% | |
# vol 25 = set volume level between 0-100 | |
re='^[0-9]+$' | |
dir= | |
if [[ "$1" == "u" ]]; then # volume up | |
dir=+ | |
elif [[ "$1" == "d" ]]; then # volume down | |
dir=- | |
elif [[ "$1" == "" ]]; then | |
echo $(osascript -e 'output volume of (get volume settings)') | |
elif [[ $1 =~ $re ]]; then | |
osascript -e "set volume output volume $1" | |
else | |
echo Control OSX Volume Level: vol '[u/d/#]' | |
fi | |
# volume up or down | |
if ! [[ -z "$dir" ]]; then | |
osascript -e "set volume output volume $(( ( $(osascript -e 'output volume of (get volume settings)') $dir 5 ) / 5 * 5))" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment