-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvol.sh
44 lines (37 loc) · 939 Bytes
/
vol.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# vol.sh
# a simple bash script for controlling volume settings on a Mac
# with help from https://coderwall.com/p/22p0ja
# - chris <[email protected]>
get () {
mute=`/usr/bin/osascript -e 'output muted of (get volume settings)'`
volume=`/usr/bin/osascript -e 'output volume of (get volume settings)'`
printf "Volume is $volume (Muted: $mute).\n\n"
}
set () {
volume=$1
/usr/bin/osascript -e 'set volume output muted false'
/usr/bin/osascript -e "set volume output volume ${1}"
}
mute () {
/usr/bin/osascript -e 'set volume output muted true'
}
unmute () {
/usr/bin/osascript -e 'set volume output muted false'
}
if [[ $1 == "get" ]]; then
get
elif [[ $1 == "set" ]]; then
set $2
get
elif [[ $1 == "mute" ]]; then
mute
get
elif [[ $1 == "unmute" ]]; then
unmute
get
else
get
printf 'Use `get` or `set N` to get or set volume levels.\n'
printf 'Also `mute` and `unmute` work too.\n\n'
fi