Last active
January 10, 2022 11:18
-
-
Save NishargShah/160915aae5278e2448a87767ce225f9c to your computer and use it in GitHub Desktop.
Help to toggle sound 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/bash | |
SINK=$(pacmd list-sinks | grep index) | |
INDEX_1=${SINK:11:2} | |
SINK=$(pacmd list-sinks | grep index | grep -vw "index: 1") | |
INDEX_2=${SINK:11:2} | |
SINK=$(pacmd list-sinks | grep "* index") | |
ACTIVE_SINK=${SINK:11:2} | |
if [ $ACTIVE_SINK = $INDEX_2 ]; then | |
echo Setting Speaker | |
pacmd set-default-sink $INDEX_1 | |
elif [ $ACTIVE_SINK = $INDEX_1 ]; then | |
echo Setting Headphone | |
pacmd set-default-sink $INDEX_2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment