9 Responses

  1. Rahul Gupta
    Rahul Gupta at |

    An alternative way to do the same in a single script (without prior knowledge of installed cards) would be

    #!/bin/bash

    oldIFS=${IFS}
    IFS=$’\n’
    cardList=($(asoundconf list | grep -v “Names of available sound cards”))
    IFS=${oldIFS}

    if [ ${#cardList[@]} -eq 1 ]
    then
    echo “The system detedted only 1 audio card”
    echo “Press enter to exit”
    read
    exit 0
    fi

    echo “Select the AUDIO card to be selected as default”
    select card in “${cardList[@]}”
    do
    if [ -n “${card}” ]
    then
    echo “Changing default-card to: ${card}”
    asoundconf set-default-card ${card}
    echo “Press enter to exit”
    read
    exit $?
    else
    echo “Please select a valid entry”
    fi
    done

  2. rojo
    rojo at |

    For a simpler (albeit less impressive) solution, you could also add a small script to your System –> Preferences –> Sessions –> Startup Programs as follows:

    #!/bin/bash
    AUD=`asoundconf list | grep ‘AUDIGY2’`
    if [ “$AUD” = “AUDIGY2” ]; then asoundconf set-default-card AUDIGY2;
    else asoundconf set-default-card IXP; fi

    There’s probably a way to call this from Udev whenever the device is hot plugged, but I don’t know how. As-is, you could either manually run the script or log off and back on to activate the appropriate sound device.

  3. Guy
    Guy at |

    Thanks – should be useful in other distros too

    Shantanu, to solve your hardware issue, see if you can make or get made a ‘y’ connection that connects both soundcards to the speakers.

  4. Adam Williamson
    Adam Williamson at |

    An auxiliary note for anyone who just wants to set one card as default *all the time*, on a non-PulseAudio system: you can /etc/modprobe.conf and use the index= option, which all ALSA drivers respect.

    If you have one card handled by snd-hda-intel and one handled by snd-ice1724 , and you wanted the snd-ice1724 card to be default, you’d add these lines:

    options snd-ice1724 index=0
    options snd-hda-intel index=1

    and that sorts it.

    If you’re using any modern distribution with PulseAudio (and you don’t have any problems with it…), you can both set a default device and move playing streams on-the-fly from one device to another in ‘pavucontrol’.

  5. Little Birdie
    Little Birdie at |

    No, you cannot detect when the speakers are plugged in. It has nothing to do with the operating system, the sound card simply does not detect what is plugged in, so there is no way for the operating system to know. Every operating system requires you to tell it what sound card you want to use for output.

  6. kortas
    kortas at |

    a way to change in pulseaudio:

    $ pacmd list-sinks | less
    $ pacmd set-default-sink [index number]

Comments are closed.