-   Slackware (
-   -   Getting audio to switch to usb headphones (

WhiteHotLoveTiger 02-25-2013 11:44 AM

Getting audio to switch to usb headphones
I've got a set of usb headphones, and I'd like to have all of my audio switch over to them when they're plugged in, rather than coming out of my laptop's speakers. Currently, my sound plays from the laptop speakers regardless of whether the headphones are plugged in or not.
When I go into kmix -> Settings -> Audio Setup, the headphones are listed as a playback device. I can select it, play the test audio, and it does come out of the headphones, even while I have audio from another source playing out of the laptop speakers at the same time.
I've moved the headphone up to the top of preference list. Now whenever I plug in/unplug the headphones I get a little pop-up message telling me that audio playback is switching to the headphones/falling back to the laptop speakers. The only problem is that my speakers keep on playing all my audio, and the headphones don't play anything.

I read through and tried

echo "options snd-hda-intel model=auto" > /etc/modprobe.d/snd-hda-intel.conf
though this had no effect, even after a restart.

My next step is to start looking through some of the more complex options on that page, but I feel like the solution should be pretty simple. After all, the headphones have played a little audio, and Slackware seems to think it's switching the playback device.
I'd love to hear any suggestions.

Lenovo ThinkPad T410
Logitech usb headphones/mic

Alien Bob 02-25-2013 12:07 PM

It will probably involve writing custom UDEV rules. Google around a bit, no distro has this fully covered, but you will find lots of good pointers, as well as scripts.
I never bothered to try them out (I do not own a USB headset but my son does).

However, if this thread accumulates good info I will collect it into a HOWTO on .


frankiej 02-25-2013 12:47 PM

I have a Logitech USB headset that I have gotten to work without any changes except in KMix -> Settings -> Audio Setup.

You said you changed the preference order. Which preference order did you change? Changing the Audio Playback level itself has no effect whatsoever, at least not for me. If I change the preferences in Audio Playback - Music, I do see things work for Amarok. I can unplug and plug in my headset and things switch back and forth just fine (it won't switch if you have the headset plugged in initially, I guess it has to see the USB device trigger).

You can do that "Apply Device List To" to make changes at the Audio Playback level and have it apply to all of the sub-types. But I struggled with that for a bit until I finally realized the top level doesn't have any direct effect.

Note that this is on a stock Slackware 14 system.

Update:I did a little more playing around and what I posted probably will not help you in your situation. I don't get the notification that it is trying to switch when I don't have the sub-type preference orders switched like I was suggesting. Sorry.

Alien Bob 02-25-2013 02:00 PM

It would be best to come up with a DE-agnostic solution. KDE is smart at switching audio playback devices on-demand, but it would be nice to find a solution which works for other desktop environments as well. Even for the console.


WhiteHotLoveTiger 02-25-2013 02:14 PM

@Bob: I'll have to take a look at UDEV later. I'll let you know if I get it working.

@frankiej: I was ititially just changing the order under music, but I later used the "Apply Device List To". Even after setting the preference order in each category, I'm still having the same problem.

Slacker B. 04-13-2013 11:12 AM


Originally Posted by Alien Bob (Post 4899492)
It would be best to come up with a DE-agnostic solution. KDE is smart at switching audio playback devices on-demand, but it would be nice to find a solution which works for other desktop environments as well. Even for the console.


Hi Alien Bob,

First off I know I'm posting in a thread that's several weeks old but I'm been attempting to resolve this on my own. I apologize for the late reply!

I've been struggling with this on my laptop and home machine for a while now. I have yet to pursue the UDEV route of getting this to work as I'm using the troubleshooting to learn more about how sound works on Linux.

Here's what I've attempted:

I did find this script which at least in my case allows me to switch between cards fairly easily:

(Taken from

% cat /usr/bin/asoundrc
# asoundrc v0.1.0 20090101 GPLv3
# asoundrc v0.2.0 20090320 GPLv3
# A simple script to create a particular default audio device regardless
# of what cards are loaded or in what order. It could be used anytime or
# placed in a ~/.bashrc script for a persistent setup every login.
# Usage: asoundrc [DEFAULT_CARD] > ~/.asoundrc

# use the first parameter as the card name, or else
# look for the sound card, discarding those that are only microphones
# when there are multiple cards, use the first one
if default_card="${1:-$(cat "$(for f in $(ls -1 /proc/asound/card[0-9]*/{midi,codec}* 2>/dev/null); do echo "${f%/*}"; done \
| sed -e '\|^[\[:blank:]\]$|d' -e 'q')/id" 2>/dev/null)}"; then
echo "Using sound card: ${default_card}" >&2
cat /proc/asound/card[0-9]*/id | \
gawk --assign default_card="${default_card}" \
'{print "pcm."$1" { type hw; card "$1"; }\nctl."$1" { type hw; card "$1"; }" }
END {print "pcm.!default pcm."default_card"\nctl.!default ctl."default_card}'
echo "Warning: No sound cards found." >&2

This allowed my to switch the primary sound device/output between my USB headset or speakers. However I'm left with the issue that only one program may use the audio device at a time. The second application attempting to use the sound gets a resource busy error. I found a suggestion on another distributions wiki on how to attempt and resolve this:

Software mixing (dmix)
Note: For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.

If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.

pcm.dsp {
type plug
slave.pcm "dmix"

I ended up creating a .asound.rc file in my home directory using the previously mentioned scirpt and attempting to append the above pcm.dsp into the .asound.rc file with the hopes that this would allow multiple applications to access the sound device. It didn't work.

dugan answered in this thread regarding a similar issue (sound only playing from one device) to disable the load_alsa_oss_modules:


Originally Posted by dugan (Post 4929576)
To get software mixing that always works, all I do is edit /etc/rc.d/rc.alsa and comment out the load_alsa_oss_modules lines. That will prevent anything from running in OSS Emulation mode. Anything running in OSS emulation mode would get exclusive use of the sound card and block everything else from using it. Anything not running in OSS emulation mode gets software mixing, and that's been true for quite a few years.

I have attempted to do so but I was still unable to get the sound to auto switch to a USB device (headset)

I'm not an expert but I am willing to attempt and find a DE solution to the problem. Would anyone have suggestions on how to work towards that solution? I think this functionality would be a great addition to Slackware desktop experience. I imagine I'm not the only one having this issue or the only one who's not familiar enough with UDEV to make it switch sound devices. All of this being said It looks like I may end up reading more on UDEV to get my sound working in the short term.

Slacker B.

DavidMcCann 04-13-2013 11:56 AM

I've never tried my usb speakers with Slackware, although Salix sorts them out in seconds with a GUI tool), but have you tried creating $HOME/.asoundrc with contents like this

defaults.pcm.card 1
defaults.pcm.device 0
defaults.ctl.card 1

Get the card number with "aplay -l".

The KDE configuration tool doesn't touch ALSA, only Phonon, which means that it words with Kinqueror but not with Firefox.

All times are GMT -5. The time now is 07:40 AM.