49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Function to get the ID of the default sink
|
|
get_default_sink_id() {
|
|
wpctl status | awk '/Sinks:/,/Sources:/' | awk '/\*/ {print $3}' | tr -d '.'
|
|
}
|
|
|
|
# Function to get the description of a sink by ID
|
|
get_sink_description() {
|
|
wpctl inspect "$1" | awk -F '"' '/node.description/ {print $2}'
|
|
}
|
|
|
|
# Get current default sink ID
|
|
current_sink_id=$(get_default_sink_id)
|
|
|
|
# If no sink found, exit
|
|
if [ -z "$current_sink_id" ]; then
|
|
echo "No default audio output device found"
|
|
exit 1
|
|
fi
|
|
|
|
# Get its description
|
|
current_description=$(get_sink_description "$current_sink_id")
|
|
|
|
# Decide target device name based on current device
|
|
case "$current_description" in
|
|
"Starship/Matisse HD Audio Controller Analog Stereo")
|
|
target_description="Yeti Stereo Microphone Analog Stereo"
|
|
;;
|
|
"Yeti Stereo Microphone Analog Stereo")
|
|
target_description="Starship/Matisse HD Audio Controller Analog Stereo"
|
|
;;
|
|
*)
|
|
target_description="Yeti Stereo Microphone Analog Stereo"
|
|
;;
|
|
esac
|
|
|
|
# Find the sink ID of the target device
|
|
target_sink_id=$(wpctl status | awk '/Sinks:/,/Sources:/' | grep "$target_description" | awk '{print $2}' | tr -d '.')
|
|
|
|
# If target sink found, switch to it
|
|
if [ -n "$target_sink_id" ]; then
|
|
wpctl set-default "$target_sink_id"
|
|
echo "Switched audio output to: $target_description"
|
|
else
|
|
echo "Target device '$target_description' not found."
|
|
exit 1
|
|
fi
|