forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoli
More file actions
executable file
·43 lines (40 loc) · 1.3 KB
/
Copy pathvoli
File metadata and controls
executable file
·43 lines (40 loc) · 1.3 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
37
38
39
40
41
42
#!/bin/bash
# set, increase, decrease, toggle volume of a sink-input (application)
#
# NOTE
# This script has bugs and doesnt work properly, will fix when get time
rm -f /tmp/voli.* &>/dev/null
pactl list sink-inputs | grep -e "Sink Input" -e "Vol" -e "application.name " > /tmp/voli.apps
numbers=$(grep -oP "Sink.*#\K\d+" /tmp/voli.apps)
names=$(grep -oP "\"\K(\w+)[ \"]" /tmp/voli.apps | cut -d'"' -f1)
volumes=$(grep -oP "Volume.*/ \K.+%" /tmp/voli.apps)
len=$(echo "$numbers" | wc -w)
for i in $(seq 1 "$len")
do
number=$(echo "$numbers" | cut -d' ' -f"$i")
name=$(echo "$names" | cut -d' ' -f"$i")
volume=$(echo "$volumes" | cut -d' ' -f"$i")
echo "$number $name $volume" >> /tmp/voli.list
done
if [ ! -e /tmp/voli.list ]; then
echo "No applications are playing sound"
exit 0
fi
roficommands="rofi -dmenu -theme flat-orange"
if sinkinput=$($roficommands -no-custom -p Which\ application? < /tmp/voli.list)
then
echo "Exiting"
exit
fi
sinkinput=$(echo "$sinkinput" | cut -d' ' -f1)
#echo "What do you want to set the value to? (+x% for increase) "
#read response
response=$($roficommands -p "What value to set? (x%, ±x%, up, down, mute )")
cmd="volume"
case $response in
up) val="+5%";;
down) val="-5%";;
mute) cmd="mute"; val="toggle";;
*) val=$response;;
esac
pactl -- set-sink-input-"$cmd" "$sinkinput" "$val"