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
47
48
49
50
51
52
53
54
55
56
#!/bin/sh # # simple pulse wrapper for controlling volume # # deps: # - pactl # - notify-send 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 -h string:x-canonical-private-synchronous:anything 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 -h string:x-canonical-private-synchronous:anything else notify-send '🔈 vol' --hint=int:value:"$vol" -t 800 -h string:x-canonical-private-synchronous:anything fi } case "$1" in ls|list) pactl list short sinks | awk '{print $1" "$2}' ;; set|use) 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 ;; *) printf "unknown command\n" exit 1 ;; esac