Usb sound card, alsa and udev

home of a content challenger

Usb sound card, alsa and udev

Found the following information on Joeys blog:

If you’re like me and had to buy a usb sound card since the laptop’s onboard soundcard creates too much noise, and would like to have that card used by default when it’s plugged in, but otherwise have builtin card be used, create an /etc/udev/rules.d/00_local.rules containing:

# Default to using additional (USB) sound cards when they are available.
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"

Only programs started after the sound card is plugged in will use it of course, and this might not work if you have it plugged in while booting.



3 Responses

  1. […] followed the instructions here to set the default automatically when plugging/unplugging: Works for me (using Debian […]

  2. helpme says:

    When I try to make the file it gives me a Permission denied, what am I doing wrong?

  3. Jord says:

    You should be root when you write that file. Either use sudo or gksudo to start your editor of choice. You could also become the root user by using ‘su -‘.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: