Last active
October 27, 2019 21:59
-
-
Save BenJuan26/d47b3980da2b5dbb6caa527348db4eca to your computer and use it in GitHub Desktop.
A simple bash script to switch between audio device sinks
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 | |
| 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