Created
September 9, 2013 01:36
-
-
Save samurai00/6490394 to your computer and use it in GitHub Desktop.
set volume on Mac using command
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 | |
let now_vol=`osascript -e 'output volume of (get volume settings)'` | |
case $1 in | |
up) | |
let vol=$now_vol+10 | |
if [ "$vol" -gt 100 ] ; then | |
vol=100 | |
fi | |
osascript -e "set volume output volume $vol" | |
echo "Volume: $vol" | |
;; | |
down) | |
let vol=$now_vol-10 | |
if [ "$vol" -lt 0 ] ; then | |
vol=0 | |
fi | |
osascript -e "set volume output volume $vol" | |
echo "Volume: $vol" | |
;; | |
[0-9]|[1-9][0-9]|100) | |
osascript -e "set volume output volume $1" | |
echo "Volume: $1" | |
;; | |
mute) | |
osascript -e 'set volume output muted true' | |
;; | |
nomute) | |
osascript -e 'set volume output muted false' | |
;; | |
*) | |
echo "useage:{up|down|0-100|mute|nomute}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment