Skip to content

Instantly share code, notes, and snippets.

@samurai00
Created September 9, 2013 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samurai00/6490394 to your computer and use it in GitHub Desktop.
Save samurai00/6490394 to your computer and use it in GitHub Desktop.
set volume on Mac using command
#!/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