#!/bin/sh

LIST=$(dmesg | grep "^uaudio.*configuration.*interface*" | sed 's/uaudio\(.\).*"\(.*\)".*/\1 - \2/g')
DEV=$(sndioctl -n server.device)
echo "Select sound device (current=$(( DEV - 1 ))):"

echo "s - System Audio (PCI)"
echo "$LIST"
echo -n "=> "
read -r

case $REPLY in
    s) sndioctl -q server.device=0; ;;
    [0-9]) sndioctl -q server.device=$(( REPLY + 1 )); ;;
esac
