-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteam-big-pic-volume-ctrl.sh
executable file
·60 lines (52 loc) · 1.06 KB
/
steam-big-pic-volume-ctrl.sh
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
#!/usr/bin/env sh
# Parameters:
# Timeout in seconds
TIMEOUT=1
bigpicture=-1
while true
do
changed=-1
found_bigpic=-1
for pid in $(pidof steam)
do
for wmid in $(xdotool search --pid "$pid")
do
if xprop -id "$wmid" -notype | grep --quiet STEAM_BIGPICTURE
then
if [ $bigpicture -ne 0 ]
then
changed=0
fi
bigpicture=0
found_bigpic=0
fi
done
done
if [ $found_bigpic -eq -1 ]
then
# Previously had Steam Big Picture open
if [ $bigpicture -eq 0 ]
then
changed=0
bigpicture=-1
else
# If we're not in big picture mode (and didn't have it open
# last time we checked), get the latest mute/volume information
muted=$(pamixer --get-mute)
volume=$(pamixer --get-volume)
fi
fi
# If big picture mode is running, set the volume
if [ $changed -eq 0 ]
then
if [ $bigpicture -eq 0 ]
then
pactl set-sink-mute @DEFAULT_SINK@ false
pactl set-sink-volume @DEFAULT_SINK@ 100%
else
pactl set-sink-mute @DEFAULT_SINK@ "$muted"
pactl set-sink-volume @DEFAULT_SINK@ "$volume%"
fi
fi
sleep $TIMEOUT
done