blob: 94423d0ef133ae93bd78c83404a237e8f926b08e (
plain) (
blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/bin/bash
rofi=($ROFI -theme-str "* {theme-color: #88ffff;}")
if [[ "$1" == "-a" ]] ; then
sinks="$(pactl list sinks | (while read line ; do
case $line in
Description:*)
descr=${line//*: }
;;
Sink\ \#*)
if [ ! -z "$sink" ] ; then
echo "$state $descr ($volume)|$sink"
fi
sink=${line//*#} ;;
Volume:*)
volume=$(sed 's/.* \([0-9]\+%\).*/\1/g' <<< "$line")
;;
*State:*)
state=${line//*: }
if [[ "$state" == 'RUNNING' ]] ; then
state='⏺'
else
state=' '
fi ;;
esac
done
echo "$state $descr ($volume)|$sink"))"
sinks="$(grep "^⏺" <<< "$sinks" ; grep -v "^⏺" <<< "$sinks")"
sink_inputs="$(pactl list sink-inputs | (while read line ; do
case $line in
*application.name\ =*)
app="${line//*= \"}"
app="${app%%\"}"
;;
*media.name\ =*)
media="${line//*= \"}"
media="${media%%\"}"
;;
*Volume:*)
volume=$(sed 's/.* \([0-9]\+%\).*/\1/g' <<< "$line")
;;
Sink\ Input\ \#*)
if [ ! -z "$sink" ] ; then
echo "⏺ $app: $media ($volume)|$sink"
fi
sink=${line//*#} ;;
esac
done
echo "⏺ $app: $media ($volume)|$sink"))"
selection=$(
(echo "$sinks" ; echo '' ; echo "$sink_inputs") | \
cut -d'|' -f1 | \
"${rofi[@]}" -p "Set Volume For")
if [[ -z "$selection" ]] ; then
echo "Cancelled" >&2
exit 0
fi
value=$(grep "$selection" <<< "$sinks")
command="set-sink-volume"
if [[ -z "$value" ]] ; then
command="set-sink-input-volume"
value=$(grep "$selection" <<< "$sink_inputs")
if [[ -z "$value" ]] ; then
echo "Invalid Selection" >&2
exit 1
fi
fi
echo "Setting $value"
value=${value//*|}
else
command="set-sink-volume"
value="@DEFAULT_SINK@"
fi
volume=$(echo '10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
110%
120%
130%' | "${rofi[@]}" -p 'Set Volume To')
echo pactl "$command" "$value" "$volume"
pactl "$command" "$value" $volume
|