Created
July 28, 2020 17:51
-
-
Save karmanyaahm/db698dbb114865ee84eefa7fe4df8ffc to your computer and use it in GitHub Desktop.
Switch between HDMI and laptop audio in pulse audio with one command
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/bash | |
#input hdmi,analog, or check | |
#you will probably have to change the specific values with information from `pacmd list-cards` before it works for your setup | |
#I am using this script with https://store.kde.org/p/1297839 | |
CARDID="9d71" | |
INP=$1 | |
if [ "$INP" == "hdmi" ]; then | |
pacmd set-card-profile alsa_card.pci-0000_00_1f.3 output:hdmi-stereo+input:analog-stereo | |
elif [ "$INP" == "analog" ]; then | |
pacmd set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo | |
elif [ "$INP" == "check" ]; then | |
#return 0 on audio hdmi and 1 otherwise | |
THISPROFILE=$(pacmd list-cards |grep -A 100 9d71 | grep -A 1 sinks |tail -n1) | |
if [[ $THISPROFILE == *"analog"* ]]; then | |
echo "analog" | |
exit 1 | |
elif [[ $THISPROFILE == *"hdmi"* ]]; then | |
echo "hdmi" | |
exit 0 | |
fi | |
# echo $THISPROFILE | |
# | |
# | |
# | |
# | |
# if [ $THISPROFILE = "hdmi" ]; then | |
# exit 0; | |
# else | |
# exit 1; | |
# fi | |
else | |
echo "input hdmi,analog, or check" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment