-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume
More file actions
executable file
·37 lines (32 loc) · 1.25 KB
/
volume
File metadata and controls
executable file
·37 lines (32 loc) · 1.25 KB
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
#!/bin/bash
# You can call this script like this:
# $./volume.sh up
# $./volume.sh down
# $./volume.sh mute
function get_volume {
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}
function is_mute {
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
}
case $1 in
up)
# Set the volume on (if it was muted)
amixer -D pulse set Master on > /dev/null
# Up the volume (+ 5%)
amixer -D pulse sset Master 10%+ > /dev/null && echo $(amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1) > /tmp/xobpipe
;;
down)
amixer -D pulse set Master on > /dev/null
amixer -D pulse sset Master 10%- > /dev/null && echo $(amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1) > /tmp/xobpipe
;;
mute)
# Toggle mute
# amixer -D pulse set Master 1+ toggle > /dev/null
if amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 3 | cut -d ']' -f 1 | grep -q 'on'; then
amixer -D pulse set Master off && echo $(amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1)! > /tmp/xobpipe
else
amixer -D pulse set Master on && echo $(amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1) > /tmp/xobpipe
fi
;;
esac