Skip to content

Instantly share code, notes, and snippets.

@uzantonomon
Last active May 18, 2017 16:02
Show Gist options
  • Save uzantonomon/a2b4639e70a3222345fc58d6415595ce to your computer and use it in GitHub Desktop.
Save uzantonomon/a2b4639e70a3222345fc58d6415595ce to your computer and use it in GitHub Desktop.
#!/bin/bash
DEVICE='alsa_output.pci-0000_00_1b.0.analog-stereo'
FIRSTDEVICE=analog-output-lineout
SECONDDEVICE=analog-output-headphones
ACTIVE_SINK=$(pacmd list-sinks | grep 'active port' | awk '{ print $3 }')
ID=1
if [ "$ACTIVE_SINK" = "<analog-output-headphones>" ]; then
echo "[*] Enabling all analog output on $DEVICE."
pacmd set-sink-port $DEVICE $FIRSTDEVICE > /dev/null
amixer -c $ID sset "Auto-Mute Mode" Disabled > /dev/null
else
echo "[*] Enabling headphones only on $DEVICE."
pacmd set-sink-port $DEVICE $SECONDDEVICE > /dev/null
amixer -c $ID sset "Auto-Mute Mode" Enabled > /dev/null
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment