blob: f0765bb9dbeb3a809f8932d29d321990a075efe9 (
plain)
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
45
46
47
48
49
50
51
|
#!/bin/sh
. slib
help() {
cat << EOF
${0}: Wrapper script to change volume
options:
-i [Vol] Increase volume by Vol
-d [Vol] Decrease volume by Vol
-s [Vol] Set volume to Vol
-p Show the current volume
-t Toggle between mute and unmute
-h Print this message and exit
EOF
exit 0
}
check_program "pactl" "pulseaudio must be installed"
[ $# != 1 ] && [ $# != 2 ] && invalid_use
while getopts "i:d:s:pth" option; do
case "${option}" in
i) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ +${OPTARG}%" ;;
d) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ -${OPTARG}%" ;;
s) run --reload-status "pactl set-sink-volume @DEFAULT_SINK@ ${OPTARG}%" ;;
t) run --reload-status "pactl set-sink-mute @DEFAULT_SINK@ toggle" ;;
p)
if ! pactl get-sink-volume @DEFAULT_SINK@ \
| sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' | head -n1 2>/dev/null; then
err "Failed to get current volume"
else
exit 0
fi
;;
h) help ;;
*) invalid_use -h ;;
esac
done
# Unreachable
invalid_use
|