Skip to content

Instantly share code, notes, and snippets.

@sortedcord
Created February 16, 2026 10:43
Show Gist options
  • Select an option

  • Save sortedcord/7ebc53e3b567ee0c5b76643eb8221b0a to your computer and use it in GitHub Desktop.

Select an option

Save sortedcord/7ebc53e3b567ee0c5b76643eb8221b0a to your computer and use it in GitHub Desktop.
Toggle Default Audio Devices
#!/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