[LAU] Alsa setup question

Ralf Mardorf ralf.mardorf at alice-dsl.net
Sat May 2 13:44:56 UTC 2015

On Sat, 2 May 2015 14:53:16 +0200, hollundertee at gmx.net wrote:
>Thanks Ralf, I already have that:
>$ cat /etc/modprobe.d/alsa-base.conf 
>options snd slots=snd_usb_audio,snd_hda_intel
>options snd_usb_audio index=0
>options snd_hda_intel index=1
>This way, the interface index is static, the question is:
>How do I get:
>if USB_device_is_present then
>	default := UA25
>	default := PCH

An insane solution:

Perhaps write a script that at startup tests if the USB device is

aplay -l | grep device_foo
then checking the exit status by
it is 1 if the device is not available and 0 if the device is

Provide two alsa-base.conf

1. options snd slots=snd_usb_audio


2. options snd slots=snd_hda_intel

make /etc/modprobe.d/alsa-base.conf a link to one or the other config.

Test if the link to the file is for the device that is available, if so
do nothing, if not link to the other config and let the script execute
shutdown -r now.

It could take the time of 1 shutdown and 2 startups and isn't good for
the HDDs, but on the quick I didn't found a way to restart alsa and
taking care of a changed /etc/modprobe.d/alsa-base.conf. To be honest, I
didn't read the alsa man pages, there might be a sane way to change the
default device.

More information about the Linux-audio-user mailing list