Last active
January 1, 2016 14:39
-
-
Save Aldarone/8158850 to your computer and use it in GitHub Desktop.
Petit script bash pour intervertir deux sinks de pulseaudio. Par exemple pour passer le son de la carte interne vers un casque usb et inversement en une pression de touche. Trouvé ici: http://snipplr.com/view.php?codeview&id=70531 et un peu adapté.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Sound output switcher using PulseAudio,libnotify | |
# | |
# by Alda <[email protected]> | |
# inspired by Mickaël Quirin <eephyne[guess what put here]gmail.com | |
# and Anton Veretenenko <anton[email sign]veretenenko.ru> | |
notify_show=1 | |
notify_delay=2000 | |
# There you must put the name of the two devices you want to permute | |
# You can find them with `pacmd list-sinks` | |
default_output_name="alsa_output.pci-0000_00_1b.0.analog-stereo" | |
alt_output_name="alsa_output.usb-0d8c_USB_Sound_Device-00-Device.analog-surround-51" | |
default_output=`pacmd list-sinks | grep -B1 "<$default_output_name>" | grep index | sed -r "s/^.* index: //"` | |
alt_output=`pacmd list-sinks | grep -B1 "<$alt_output_name>" | grep index | sed -r "s/^.* index: //"` | |
active_device=`pacmd list-sinks | grep -i -E '\* index' | sed -r "s/^.*\* index: //"` | |
active_device=`pacmd list-sinks | grep -i -E '\* index' | sed -r "s/^.*\* index: //"` | |
if [ "$active_device" == "$alt_output" ] | |
then | |
pacmd "set-default-sink $default_output" | |
test=`pacmd list-sink-inputs | grep -i -E 'index:'` | |
while read -r line; | |
do | |
sink=(`echo $line | sed -r s/^.*index:\ //`) | |
pacmd move-sink-input $sink $default_output; | |
done <<< $test | |
if [ $notify_show -eq 1 ] | |
then | |
notify-send -u normal -t $notify_delay -i gnome-sound-properties "Alternative OFF" "Sound output switched to internal audio" | |
fi | |
else | |
pacmd "set-default-sink $alt_output" | |
test=`pacmd list-sink-inputs | grep -i -E 'index:'` | |
while read -r line; | |
do | |
sink=(`echo $line | sed -r s/^.*index:\ //`) | |
pacmd move-sink-input $sink $alt_output; | |
done <<< $test | |
if [ $notify_show -eq 1 ] | |
then | |
notify-send -u normal -t $notify_delay -i gnome-sound-properties "Alternative ON" "Sound output switched to alternative audio" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment