4

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.

3 Answers 3

9

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.

1
  • 1
    I didn't know about "Auto-Mute" and that solved my issues. Thanks so much for such a details answer
    – Felipe
    Apr 20, 2022 at 16:42
0

You can toggle with a shortcut using this on-liner:

[[ $(pacmd list-cards | grep "active profile" | cut -d " " -f 3-) = "<output:hdmi-stereo-extra1+input:analog-stereo>" ]] && pacmd set-card-profile 0 "output:analog-stereo+input:analog-stereo" || pacmd set-card-profile 0 "output:hdmi-stereo-extra1+input:analog-stereo"

In this case the alternatives are hdmi-stereo-extra1+input:analog-stereo and output:analog-stereo+input:analog-stereo. List your profiles available with:

pacmd list-cards | grep "output:" | grep -v "available: no"
0

The helpful one-liner given by Pablo A can be set into bash script as follows (and, in GNOME at least, set as an application shortcut):-

#!/bin/bash

AudJk=$(pacmd list-cards | grep "active profile" | grep "output:" | cut -d " " -f 3-)
HDMI="output:hdmi-stereo+input:analog-stereo"
HdFn="output:analog-stereo+input:analog-stereo"

[[ $AudJk = "<$HDMI>" ]] && pacmd set-card-profile 0 $HdFn || pacmd set-card-profile 0 $HDMI

I'm new to scripting but...

...hopefully the rendition of the card profile strings into variables makes it a little easier to understand?

...perhaps there is a more elegant way of performing the first logical test as [[ $AudJk = "<$HDMI>" ]] may not not be optimum?

...maybe there is a simpler, built-in method of referencing the output profile than using grep "output:" but as far as we can see there is no function in pacmd.

Hope this helps some.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .