-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTray_icon_audio_output_switcher
27 lines (21 loc) · 1.04 KB
/
Tray_icon_audio_output_switcher
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
#!/bin/sh
#sudo apt install yad
#sudo apt-get install pulseaudio
function switch_audio_sink() {
# Démarrer PulseAudio
pulseaudio --start
# Obtenir les index des deux premiers périphériques audio
SINK_INDEX1=$(pacmd list-sinks | grep 'index:' | grep -o '[0-9]*' | head -n 1 | tail -n 1)
SINK_INDEX2=$(pacmd list-sinks | grep 'index:' | grep -o '[0-9]*' | head -n 2 | tail -n 1)
# Obtenir le périphérique audio actif
ACTIVE_SINK=$(pacmd list-sinks | grep '* index:' | grep -o '[0-9]*')
# Changer le périphérique audio par défaut en fonction de l'index actif
if [ "$ACTIVE_SINK" = "$SINK_INDEX1" ]; then
pacmd set-default-sink "$SINK_INDEX2"
else
pacmd set-default-sink "$SINK_INDEX1"
fi
}
# Exporter la fonction pour la rendre accessible depuis un autre processus
export -f switch_audio_sink
yad --notification --no-middle --command='bash -c "switch_audio_sink"' --image=audio-card-symbolic --text="Switch audio output" --menu='Switch audio output!bash -c "switch_audio_sink"||Quit!quit'