#!/usr/bin/env bash

set -e

SINK="alsa_output.usb-Anker_PowerConf_A3321-DEV-SN1-01.analog-stereo"
SOURCE="alsa_input.usb-Anker_PowerConf_A3321-DEV-SN1-01.mono-fallback"

echo "🔊 Checking PulseAudio..."
if ! pactl info >/dev/null 2>&1; then
    echo "❌ PulseAudio is not running"
    exit 1
fi

echo "✅ PulseAudio is running"

echo "🎧 Setting default speaker → PowerConf"
pactl set-default-sink "$SINK"

echo "🎤 Setting default microphone → PowerConf"
pactl set-default-source "$SOURCE"

echo
echo "📋 Current PulseAudio defaults:"
pactl info | grep -E "Default Sink|Default Source"

echo
echo "✅ PowerConf audio routing applied successfully"
