#!/bin/bash
#
# /etc/hotplug/usb/alsasound
#
# Sets up newly plugged in USB audio/MIDI devices.
#

function add_alsa () {
    # check alsa is already running
    if [ ! -d /proc/asound ]; then
	# start alsasound script, so that static devices are properly loaded
	echo "Starting ALSA..."
	/etc/init.d/alsasound start >/dev/null 2>&1
    fi
    /sbin/modprobe snd-usb-audio
}

function remove_alsa () {
    /sbin/modprobe -r snd-usb-audio
}

case "$ACTION" in
add)
  add_alsa
  ;;
remove)
  remove_alsa
  ;;
esac
