-
Notifications
You must be signed in to change notification settings - Fork 0
/
volumewizard
executable file
·55 lines (47 loc) · 1.14 KB
/
volumewizard
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
52
53
54
55
#!/bin/sh
if [ ! "$NO_COLOR" = 1 ]; then
bold="\033[1m"
reset="\033[m"
else
bold=""
reset=""
fi
if ! command -v wpctl > /dev/null || ! command -v herbe; then
if ! command -v wpctl && ! command -v herbe; then
error "wireplumber and herbe not found"
elif ! command -v wpctl; then
error "wireplumber not found"
elif ! command -v herbe; then
error "wireplumber not found"
fi
exit
fi
send_notification() {
volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | tr -dc '0-9' | sed 's/^0\{1,2\}//')
if wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q "MUTED"; then
env HERBE_ID=/9993 herbe "volume: muted"
else
env HERBE_ID=/9993 herbe "volume: $volume%"
fi
}
case $1 in
up)
# Set the volume on (if it was muted)
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+
;;
down)
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-
;;
mute)
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
;;
*)
printf "%b" "${bold}volumewizard${reset}: volume control wrapper for wpctl
${bold}Usage${reset}: volumewizard [up|down|mute]
" >&2
exit
;;
esac
send_notification