-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvolfy
More file actions
executable file
·63 lines (55 loc) · 1.48 KB
/
Copy pathvolfy
File metadata and controls
executable file
·63 lines (55 loc) · 1.48 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#Autor: Yago Ésquines
#Email: yago.fut@gmail.com
#Ano: 2020
#Dependencia: pactl
#Volfy é um Script para Usar como Comando a fim de alterar o volume de uma aplicação espefica especificas, por exemplo, o spotify.
CHECK_NUMBER='^[0-9]+%$'
CLIENTS=$(pactl list sink-inputs | grep "application.name =" | awk '{print $3}' | sed 's,",,g' )
if [ "$1" != "--help" -a -n "$1" ];then
#Validando Parametros do Comando
for NAME in ${CLIENTS,,}
do
if [ ${NAME} == ${1,,} ]; then
APPLICATION=${1,,};
if [[ $2 =~ $CHECK_NUMBER ]]; then
VOLUME=$2;
else
echo "[ERR] Volume isn't a Percent Number (Example: 10%)";
exit 1;
fi
break;
fi
done
if [ -z $APPLICATION ]; then
echo -e "[WARN] Invalid Client\n\nPossible Clients:\n\n${CLIENTS,,}";
exit 2;
fi
#Coletando Client ID
CLIENT_ID=$(pactl list clients short | grep ${APPLICATION} | awk '{print $1}');
#Coletando Sink Number
for ID in $CLIENT_ID
do
CHECK=$(pactl list sink-inputs short | grep $ID | awk '{print $1}');
if [ -n "$CHECK" ]; then
SINK_NUMBER=$(echo $CHECK | awk '{print $1}');
break;
fi
done
#Alterando o Volume da Aplicação
if [ -n $SINK_NUMBER ]; then
pactl set-sink-input-volume $SINK_NUMBER $VOLUME || exit 3;
else
echo "[ERR] Command failed - Sink Number is Wrong"
exit 3
fi
else
# --help
echo -e "
Syntax:
volfy client volume_percent
Error Code:\n
1 - Invalid Volume Value
2 - Invalid Client Value
3 - Sink Number failed - See 'pactl list sink-inputs'\n";
fi