-
-
Save nclundsten/32ae8c8d6e0ea7d8caf0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
SINK_SPEAKERS="alsa_output.pci-0000_00_1b.0.analog-stereo" | |
SINK_HEADPHONES="alsa_output.usb-Logitech_Logitech_G930_Headset-00-Headset.analog-stereo" | |
pacmd stat | grep "Default sink name" | grep --quiet "$SINK_SPEAKERS" | |
if [ $? == 0 ] | |
then | |
pacmd set-default-sink "$SINK_HEADPHONES" \ | |
&& pacmd list-sink-inputs | grep index | awk '{print $2}' | xargs -I sinkindex pacmd move-sink-input sinkindex "$SINK_HEADPHONES" \ | |
&& pacmd play-file /usr/share/sounds/freedesktop/stereo/bell.oga "$SINK_HEADPHONES" | |
else | |
pacmd set-default-sink "$SINK_SPEAKERS" \ | |
&& pacmd list-sink-inputs | grep index | awk '{print $2}' | xargs -I sinkindex pacmd move-sink-input sinkindex "$SINK_SPEAKERS" \ | |
&& pacmd play-file /usr/share/sounds/freedesktop/stereo/bell.oga "$SINK_SPEAKERS" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment