How to switch between headphones and speakers without disconnecting

5,245

1. Software switching support

Check, if your sound card supports software switching for the front audio panel. Some older motherboards don't support software switching at all. Some sound cards have connectors for both variants on the motherboard: software and hardware switching. In this case, make sure from your motherboard manual, that you use the connector with software switching.

2. Alsamixer Auto-Mute

Auto-Mute is a feature of Alsa. It ensures that when you connect your headphones, the other audio outputs are automatically muted. You can find and disable this in alsamixer. Open AlsaMixer, choose your sound card with F6 then move with < and > and find Auto-Mute. If it's enabled, disable it with the down arrow key.

3. PulseAudio configuration

This was the most problematic part for me because PulseAudio is poorly documented. When I disabled AutoMute in the previous step, speakers played in both cases. No matter, if I switched to Headphones or Line-out.

So what I had to do was look into AlsaMixer again and understand, how the volume bars react to audio switching in settings or pavucontrol.

Line-out: AlsaMixer Line-out

Headphones: AlsaMixer Headphones

As you can see, after switching to headphones, almost all volume bars got muted. But as I found out after a while, the volume of my speakers is for some reason controlled by Front bar. So now the last thing I had to do, was to configure PulseAudio to mute this Front volume-bar after switching to headphones.

PulseAudio configuration files we need to edit are stored in /usr/share/pulseaudio/alsa-mixer/paths/. In my case, I only edited the file analog-output-headphones.conf but this may vary depending on the configuration. You have to edit the file as root to contain these lines:

[Element Front]
switch = off
volume = off

Once you are done, save the file and restart PulseAudio with pulseaudio -k.

Output switching should now work as expected.

Share:
5,245
BlueManCZ
Author by

BlueManCZ

Updated on September 18, 2022

Comments

  • BlueManCZ
    BlueManCZ over 1 year

    When I connect my headphones into the front jack, my speakers (line-out) get muted. I would like to switch to speakers without disconnecting my headphones. I see two possible options in gnome-control-center and pavucontrol: Headphones and Line-out. But when I switch to line-out, I hear nothing. How can I set correct behaviour?

    I have Realtek ALC1150 with Alsa and PulseAudio installed.

  • Felipe
    Felipe about 2 years
    I didn't know about "Auto-Mute" and that solved my issues. Thanks so much for such a details answer