-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange-volume-app.sh
More file actions
30 lines (24 loc) · 913 Bytes
/
Copy pathchange-volume-app.sh
File metadata and controls
30 lines (24 loc) · 913 Bytes
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
#!/bin/sh
# based on https://unix.stackexchange.com/a/209047
# Sample usage: ./change-colume-app.sh chromium 50
# Set Chromium volume at 50% (on some systems you can go up to 120%)
LANGUAGE="en_US"
app_name="$1"
volume="$2"
current_sink_num=''
sink_num_check=''
app_name_check=''
pactl list sink-inputs |while read line; do \
sink_num_check=$(echo "$line" |sed -rn 's/^Sink Input #(.*)/\1/p')
if [ "$sink_num_check" != "" ]; then
current_sink_num="$sink_num_check"
else
app_name_check=$(echo "$line" \
|sed -rn 's/application.name = "([^"]*)"/\1/p')
if [ "$app_name_check" = "$app_name" ]; then
echo "$current_sink_num" "$app_name_check"
pactl set-sink-input-volume "$current_sink_num" "$volume"%
notify-send -a change-volume -i multimedia-audio-player "Volume set" "$app_name volume set to $volume"
fi
fi
done