Last active
May 29, 2022 10:55
-
-
Save Hiradur/27bc0cf531696991ef5ec2b5fb536218 to your computer and use it in GitHub Desktop.
Shell script to toggle Pulseaudio output profile between stereo and surround sound on the same audio device
This file contains 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/sh | |
# toggle_stereo_surround.sh | |
# Original author: Hiradur | |
# License: CC0 | |
# This script toggles between stereo and surround output. | |
# It is useful e.g. if you your AVR only provides matrix-decoding of surround | |
# sound for stereo sources. | |
# The sink name might need to be changed based on what `pacmd stat` lists as | |
# the default sink for the desired output device in stereo and surround | |
# configuration | |
# use `pacmd list-cards"to determine correct values | |
CARD_INDEX=0 | |
STEREO_PROFILE_NAME=output:hdmi-stereo-extra1 | |
SURROUND_PROFILE_NAME=output:hdmi-surround-extra1 | |
# use `pacmd stat | grep "Default sink name:"` to determine correct values for | |
# each configuration | |
STEREO_SINK_NAME=alsa_output.pci-0000_02_00.1.hdmi-stereo-extra1 | |
SURROUND_SINK_NAME=alsa_output.pci-0000_02_00.1.hdmi-surround-extra1 | |
# switch from stereo to surround | |
if (pacmd stat | grep "Default sink name: $STEREO_SINK_NAME") > /dev/null ; then | |
pacmd set-card-profile "$CARD_INDEX" "$SURROUND_PROFILE_NAME" | |
pacmd set-default-sink "$SURROUND_SINK_NAME" | |
# switch from surround to stereo | |
elif (pacmd stat | grep "Default sink name: $SURROUND_SINK_NAME") > /dev/null ; then | |
pacmd set-card-profile "$CARD_INDEX" "$STEREO_PROFILE_NAME" | |
pacmd set-default-sink "$STEREO_SINK_NAME" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to meet up and have a beautiful night