Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running Funtoo Linux, a Gentoo derivative. My two new Plantronics USB headsets (one wired, one wireless) work nicely. I plug one in, ALSA notices it, and if I manually set an application to use it instead of the default devices, it will.

I'd prefer to simply have the headset become my default input/output when present, and have the default revert to my on-board speakers otherwise. How do I automate this kind of switch?

share|improve this question
    
offtopic: thanks for adding funtoo tag –  Cynede Dec 15 '11 at 10:11

4 Answers 4

You can use udev rules. For this, you'll need to find the device attributes that distinguish your USB headset once it is plugged in. This can be usually done in two steps:

  • Run udevadm monitor --udev befor plugging the device. Then plug it in. There will be a bunch of output lines - just pick one and copy the device path from it - it is something like /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0.

  • With the headset still connected, use udevadm info --path=/your/device/path --attribute-walk to find some attributes that distinguish your device from others (like ATTR{idVendor} and ATTR{idProduct}).

When you have that, you can construct a udev rule to be triggered on connecting the device. Look at the files under /etc/udev/rules.d/ for how these look like. The one you will probably be constructing will end with RUN+="some command". Note that the identifiers (SUBSYSTEM=, ATTRS= etc.) used in such line must all come from the description of the same device - the same chunk of udevadm info --attribute-walk output.

The second part of the task is to find amixer settings that suits your needs for each scenario and wrap them in a command that you'll put in the RUN+= part of udev rule. With that, I cannot help you as I don't have similar hardware.

share|improve this answer

If you don't have it yet, pulseaudio will give you this kind of flexibility in a really easy to use routing console called pavucontrol. The preferred and fallback devices can be set per application and system defaults.

share|improve this answer
1  
And the change of output device is transparent to the application (if it uses pulseausio) - you don't have to restart the application for a change of e.g. output device - it is even possible to change output devices during playback. –  maxschlepzig Aug 25 '11 at 9:55

As Caleb mentioned, PulseAudio lets you migrate streams from one device to another.

To switch automatically, rather than manually through pavucontrol, add the module-switch-on-connect module to your PulseAudio configuration as described here:

http://askubuntu.com/questions/158241/automatically-change-sound-input-output-device/158250#158250

share|improve this answer
    
Also note that there are CLI built-in tools for controlling PA (pacmd and pactl). –  HalosGhost Jun 20 at 18:35

I just bought a Plantronics headset, and had the same problem, it was solved by following http://alsa.opensrc.org/MultipleCards :

Edited /etc/modprobe.d/50-alsa.conf file to set the default order:

options snd slots=snd-usb-audio,snd-hda-intel

I also deleted all other related configurations, namely /etc/modprobe.d/50-sound*.

I checked plugin/unplugin the headset and looking at the output of aplay -l

This was using openSUSE 12.2 and Plantronics .Audio 655.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.