HOW-TO have an USB speaker/headset autoconfigured on Debian/Etch when plugged in... I don't know why i have had to search this myself while neither Debian nor Linux in general is my prefered system. People out there seems to like complicated things for a simple need. Heh, who knows? Maybe they think it's fun to learn modprobe + ALSA scripts + udev in a row, especially at 4:00 a.m. Keywords: Debian Etch udev USB ALSA auto configure 1) First step: Go to root and run alsaconf, so that it will generate a default modprobe file. folays@leonesse:~$ su Password: leonesse:/home/folays# alsaconf When it will ask you if you want to modify /etc/modprobe.d/sound, say Yes. You should have now an /etc/modprobe.d/sound file, similary to this one: <<< alias snd-card-0 snd-intel8x0 options snd-intel8x0 index=0 >>> Of course, you can have something different that snd-intel8x0 for your setup, it's hardware- dependent. The index= field hints the system about the priority of the device, the lower being favorite. Change index=0 to index=2 for your native sound card. I also had to add the following for my integrated ac97 modem which account for a sound card: <<< alias snd-card-1 snd-intel8x0m options snd-intel8x0m index=3 >>> You can pinpoint the name of the offending module by launching (as root) udevmonitor to watch the last line like "UDEV [timestamp] add@/module/" which should be above another line "UEVENT/UDEV [timestamp] add@/class/sound/{dspX,controlCX}": <<< leonesse:/home/folays# udevmonitor udevmonitor prints the received event from the kernel [UEVENT] and the event which udev sends out after rule processing [UDEV] [...] UDEV [1211772049.223883] add@/module/snd_usb_audio [...] UEVENT[1211772049.333136] add@/class/sound/dsp1 >>> Now, plug in your USB headset and look at /var/log/messages for it's driver name, mine being snd-usb-audio. Then, append it to /etc/modprobe.d/sound in aim of finally have the following: leonesse:/etc/modprobe.d# cat sound alias snd-card-0 snd-intel8x0 options snd-intel8x0 index=2 alias snd-card-1 snd-intel8x0m options snd-intel8x0m index=3 alias snd-card-1 snd-usb-audio options snd-usb-audio index=1 Note that snd-usb-audio has index=1, so that when plugged, it should take the precedence over the integrated sound card. We purposedly(?) omitted a device with index=0, so that we can manage ourselves all symbolics links pointing to the real devices which primary files will be /dev/dspX, /dev/snd/controlCX. Beware to not let junk files in the /etc/modprobe.d/ area misstakenly took into account. 2) Second step: Add into udev configuration files a program to be executed for those devices. Change directory to /etc/udev/rules.d/, create a new local.rules file and have the following: leonesse:/etc/udev# cat /etc/udev/rules.d/local.rules KERNEL=="controlC[0-7]|dsp[0-7]", RUN+="/lib/udev/alsa-link $kernel $number" 3) Third step: Create the udev program script to be executed upon add/remove actions. <<< leonesse:/etc/udev# cat /lib/udev/alsa-link #!/bin/sh { case "$1" in dsp*) TARGET="${DEVNAME%/$1}/dsp" ;; controlC*) TARGET="${DEVNAME%/$1}/controlC0" ;; esac rm $TARGET SOURCE="`ls ${DEVNAME%$2}* | head -n 1`" SOURCE="${SOURCE##*/}" case "$ACTION" in add|remove) ln -fs $SOURCE $TARGET ;; esac } & exit 0 >>> Basically, what it will do is create a symbolic file named /dev/dsp and /dev/snd/controlC0 each respectively having the priority device as a target. It could behave in some bad way if you did not carefully followed instructions. 4) Fourth step: Go for a ride! Unplug your USB headset, /dev/dsp and /dev/snd/controlC0 should link to the native sound card: folays@leonesse:~$ ls -l /dev/dsp* /dev/snd/controlC* lrwxrwxrwx 1 root root 4 2008-05-26 05:20 /dev/dsp -> dsp2 crw-rw---- 1 root audio 14, 35 2008-05-26 05:11 /dev/dsp2 crw-rw---- 1 root audio 14, 51 2008-05-26 05:11 /dev/dsp3 lrwxrwxrwx 1 root root 9 2008-05-26 05:20 /dev/snd/controlC0 -> controlC2 crw-rw---- 1 root audio 116, 64 2008-05-26 05:11 /dev/snd/controlC2 crw-rw---- 1 root audio 116, 96 2008-05-26 05:11 /dev/snd/controlC3 Plug it back again, the symbolic links should now target the USB headset device files: folays@leonesse:~$ ls -l /dev/dsp* /dev/snd/controlC* lrwxrwxrwx 1 root root 4 2008-05-26 05:20 /dev/dsp -> dsp1 crw-rw---- 1 root audio 14, 19 2008-05-26 05:20 /dev/dsp1 crw-rw---- 1 root audio 14, 35 2008-05-26 05:11 /dev/dsp2 crw-rw---- 1 root audio 14, 51 2008-05-26 05:11 /dev/dsp3 lrwxrwxrwx 1 root root 9 2008-05-26 05:20 /dev/snd/controlC0 -> controlC1 crw-rw---- 1 root audio 116, 32 2008-05-26 05:20 /dev/snd/controlC1 crw-rw---- 1 root audio 116, 64 2008-05-26 05:11 /dev/snd/controlC2 crw-rw---- 1 root audio 116, 96 2008-05-26 05:11 /dev/snd/controlC3 Of couse, applications that do not purposely look for files changes/notifications will have to be restarted for taking the new device into account. === Diagnostic === At any time, for debugging needs you can unload/reload your drivers modules with the following: leonesse:/home/folays# modprobe -v (load the module) leonesse:/home/folays# modprobe -v -r (unload it) Where module name can be the following in my setup: - snd-intel8x0, snd-intel8x0m, snd-usb-audio At any time, you can list your PCI adapters: leonesse:/home/folays# lspci | grep -i audio You can also list your loaded modules: leonesse:/home/folays# lsmod | grep -i snd You would want to show what audio devices may be available in userland: folays@leonesse:~$ aplay -l [...] (Basically this executable will solely look for /dev/dsp* files...) udevmonitor can show you a lot of information on what's happening to dynamic device management: leonesse:/home/folays# udevmonitor --env And finally, alsamixer will allow you to change the mixer configuration: folays@leonesse:~$ alsamixer For the latter, the /dev/snd/controlC0 needs to be a valid file to works (and symbolic link are okay), while most programs would probably only needs the /dev/dsp file.