Last active
December 25, 2020 19:59
-
-
Save jackblk/bc0a8ddda41e71954b0c1743803eacfb to your computer and use it in GitHub Desktop.
Toogle PulseAudio output ports, disable/enable Auto-Mute Mode on Linux
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 | |
DEVICE='0' # Index/name of the device in `pacmd list-sinks` | |
CARD='1' # Card index in `cat /proc/asound/cards` | |
ACTIVE_SINK=$(pacmd list-sinks | grep 'active port' | awk '{ print $3 }') | |
if [ "$ACTIVE_SINK" = "<analog-output-headphones>" ]; then | |
echo "[*] Enabling all analog output on $DEVICE." | |
pacmd set-sink-port "$DEVICE" analog-output-lineout | |
amixer -c "$CARD" sset 'Auto-Mute Mode' Disabled | |
else | |
echo "[*] Enabling headphones only on $DEVICE." | |
pacmd set-sink-port "$DEVICE" analog-output-headphones | |
amixer -c "$CARD" sset 'Auto-Mute Mode' Enabled | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment