HEADSET_NAME="PRO X Wireless Gaming Headset Analog Stereo"
SPEAKER_NAME="Starship/Matisse HD Audio Controller Analog Stereo"
# ---------------------
# Get the ID of the current default sink
CURRENT_ID=$(wpctl inspect @DEFAULT_AUDIO_SINK@ | grep "node.id" | awk '{print $3}')
# Find the IDs for your specific devices using wpctl status
# We grep for the name, get the line, and extract the ID number from the start of the line
HEAD_ID=$(wpctl status | grep "$HEADSET_NAME" | grep -oE "^ │\s+[0-9]+" | tr -d ' │')
SPKR_ID=$(wpctl status | grep "$SPEAKER_NAME" | grep -oE "^ │\s+[0-9]+" | tr -d ' │')
# Logic to switch
if [ "$CURRENT_ID" == "$HEAD_ID" ]; then
echo "Switching to Speakers (ID: $SPKR_ID)..."
wpctl set-default $SPKR_ID
notify-send -t 2000 "Audio Output" "Switched to Speakers"
else
echo "Switching to Headset (ID: $HEAD_ID)..."
wpctl set-default $HEAD_ID
notify-send -t 2000 "Audio Output" "Switched to Headset"
fi
HEADSET_NAME="PRO X Wireless Gaming Headset Analog Stereo"
SPEAKER_NAME="Starship/Matisse HD Audio Controller Analog Stereo"
# ---------------------
# Get the ID of the current default sink
CURRENT_ID=$(wpctl inspect @DEFAULT_AUDIO_SINK@ | grep "node.id" | awk '{print $3}')
# Find the IDs for your specific devices using wpctl status
# We grep for the name, get the line, and extract the ID number from the start of the line
HEAD_ID=$(wpctl status | grep "$HEADSET_NAME" | grep -oE "^ │\s+[0-9]+" | tr -d ' │')
SPKR_ID=$(wpctl status | grep "$SPEAKER_NAME" | grep -oE "^ │\s+[0-9]+" | tr -d ' │')
# Logic to switch
if [ "$CURRENT_ID" == "$HEAD_ID" ]; then
echo "Switching to Speakers (ID: $SPKR_ID)..."
wpctl set-default $SPKR_ID
notify-send -t 2000 "Audio Output" "Switched to Speakers"
else
echo "Switching to Headset (ID: $HEAD_ID)..."
wpctl set-default $HEAD_ID
notify-send -t 2000 "Audio Output" "Switched to Headset"
fi