bin/vol
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
#!/bin/sh -e
#
# simple pulse wrapper for controlling
# audio stuff i care about
get_current_volume_percent() {
percent="$(pactl get-sink-volume @DEFAULT_SINK@ | awk '/Volume/ {print $5}')"
strip_perc="$(printf "%s" "$percent" | cut -d '%' -f 1)"
printf "%s" "$strip_perc"
}
notify_current_volume() {
vol="$(get_current_volume_percent)"
if [ "$vol" -gt 100 ]; then
# prevent volumes of >100% for the
# good of all ears
pactl set-sink-volume @DEFAULT_SINK@ 100%
notify-send '🔈 vol' --hint=int:value:100 -t 800
elif [ "$vol" -lt 0 ]; then
# prevent volumes of <0% for the
# good of all ... dog... whateij fiwjoefj
pactl set-sink-volume @DEFAULT_SINK@ 0%
notify-send '🔈 vol' --hint=int:value:0 -t 800
else
notify-send '🔈 vol' --hint=int:value:"$vol" -t 800
fi
}
case "$1" in
ls|list) pactl list short sinks ;;
set) pactl set-default-sink "$2" ;;
[0-9]*)
pactl set-sink-volume @DEFAULT_SINK@ "$1"%
notify_current_volume
;;
up)
# expect $2 = % to increase
pactl set-sink-volume @DEFAULT_SINK@ +"$2"%
notify_current_volume
;;
down)
pactl set-sink-volume @DEFAULT_SINK@ -"$2"%
notify_current_volume
;;
*) ;;
esac