Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When plugging a USB sound card may sometimes cause the current audio output (ie. Banshee and PC speakers) to switch immediately. But the volume controls (sound widget in systray, volume keyboard keys) are stuck on the old sound card.

Plug a soundcard and amplifier while the volume is set to ultra high for the pc speakers. You can't control the volume without opening the sound settings or alsamixer. This could probably cause neighbour disturbance in some countries. You can't control it with the sound widget of the systray nor the volume keyboard keys.

How to disable auto switch of hardware audio output, or enable auto switch of software volume controls ? It would be great to make the software behaviour consistent with the hardware's.

Ubuntu 11.10 vanilla up to date.

share|improve this question
    
Not a solution, but one workaround is to plug and unplug headphones. This forces a toggle of the controls. –  hbdgaf Mar 20 '12 at 9:05
    
Instead of hotplugging, again this is a band aid solution, perhaps you can leave it plugged in and when not in use manually switch its profile to 'off'? –  AyaneForever May 10 '12 at 19:38
3  
Third band-aid solution: turn down the hardware volume on your usb sound card prior to plugging it in--generally the best practice with all audio devices (digital and analog) is to zero all levels before hitching things together. –  adempewolff May 24 '12 at 9:32
add comment

1 Answer 1

up vote 2 down vote accepted

You can achive what you want by using an udev rule that is written to act upon certain events. In this case these events are to plug usb sound card and to unplug it. According to this forum answer, possible solution is like following:

  1. Open the file that has usb sound card udev rules:

    sudo -H nautilus /etc/udev/rules.d/10-usb-sound-card.rules
    
  2. Paste and copy

    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'"
    
  3. Save the file and give

    sudo udevadm trigger --action=add /etc/udev/rules.d/10-usb-sound-card.rules
    

command. Then test this rule by pluging and unpluging your usb sound card.

I hope this will help you.

share|improve this answer
add comment

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.