Created
February 16, 2026 10:43
-
-
Save sortedcord/7ebc53e3b567ee0c5b76643eb8221b0a to your computer and use it in GitHub Desktop.
Toggle Default Audio Devices
This file contains hidden or 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 | |
| HEADSET="alsa_output.usb-Generic_AB13X_USB_Audio_20210926172016-00.analog-stereo" | |
| LAPTOP="alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Headphones__sink" | |
| CURRENT=$(pactl info | awk -F': ' '/Default Sink/ {print $2}') | |
| if [ "$CURRENT" = "$HEADSET" ]; then | |
| NEW="$LAPTOP" | |
| MSG="Audio → Laptop" | |
| else | |
| NEW="$HEADSET" | |
| MSG="Audio → Headset" | |
| fi | |
| pactl set-default-sink "$NEW" | |
| # Move existing audio streams | |
| for input in $(pactl list short sink-inputs | awk '{print $1}'); do | |
| pactl move-sink-input "$input" "$NEW" | |
| done | |
| notify-send "$MSG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment