From 24c0f1764807875bc2036199496fb0407024aa05 Mon Sep 17 00:00:00 2001 From: Aaron Langham <124449717+Aaron-Langham@users.noreply.github.com> Date: Sat, 6 Jul 2024 14:30:58 +0100 Subject: [PATCH] Add files via upload --- soundswitcher | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 soundswitcher diff --git a/soundswitcher b/soundswitcher new file mode 100644 index 0000000..707bee8 --- /dev/null +++ b/soundswitcher @@ -0,0 +1,26 @@ +#!/bin/bash + +# Get the names of the first two audio sinks +DEV1_NAME=$(pactl list sinks short | awk 'NR==1 {print $2}') +DEV2_NAME=$(pactl list sinks short | awk 'NR==2 {print $2}') + +# Get the current default sink +CURRENT_SINK=$(pactl get-default-sink) + +# Function to switch to the other sink +switch_sink() { + if [ "$CURRENT_SINK" = "$DEV1_NAME" ]; then + pactl set-default-sink "$DEV2_NAME" + echo "Switched to $DEV2_NAME" + else + pactl set-default-sink "$DEV1_NAME" + echo "Switched to $DEV1_NAME" + fi +} + +# Print current status +echo "Current default sink: $CURRENT_SINK" +echo "Available sinks: $DEV1_NAME, $DEV2_NAME" + +# Switch to the other sink +switch_sink