Skip to content

Instantly share code, notes, and snippets.

@BenJuan26
Last active October 27, 2019 21:59
Show Gist options
  • Select an option

  • Save BenJuan26/d47b3980da2b5dbb6caa527348db4eca to your computer and use it in GitHub Desktop.

Select an option

Save BenJuan26/d47b3980da2b5dbb6caa527348db4eca to your computer and use it in GitHub Desktop.
A simple bash script to switch between audio device sinks
#!/bin/bash
CURRENT_PROFILE=$(pactl list sinks | grep "Active Port" | cut -d ' ' -f 3-)
NOTIFICATION_DURATION_MS=2000
notify() {
notify-send --hint=int:transient:1 -t $NOTIFICATION_DURATION_MS "Sound Switch" "$1"
}
amixer -c0 set "Auto-Mute Mode" Disabled
if [ "$CURRENT_PROFILE" = "analog-output-lineout" ]; then
pactl set-sink-port 0 "analog-output-headphones"
amixer -c0 set Front 0% > /dev/null
amixer -c0 set Headphone 100% > /dev/null
notify "Sound output switched to speakers"
else
pactl set-sink-port 0 "analog-output-lineout"
amixer -c0 set Headphone 0% > /dev/null
amixer -c0 set Front 100% > /dev/null
notify "Sound output switched to headphones"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment