Sound output automatically switches to HDMI

Hello,
I am using EendeavourOS with GNOME, and the latest kernels.

When I plug in my external monitor, the sound switches to it, and I always need to manually change back to the initial source. Is this the desired behavior?

Could I turn this off, so the output won’t change from the laptop speaker to HDMI?

Hello @nandor23 ,
Maybe it’s not optimal or a bit barbaric settings of mine:
yay -S pulseaudio
y to replace pipewire when asked
yay -S pulsemixer
cat .config/autostart/soundonhdmi.desktop

[Desktop Entry]
Name=MySound
GenericName=Sound on HDMI
Comment=tuctuc
Exec=/home/a/pipe2pulse.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

cat pipe2pulse.sh

#!/bin/bash
systemctl --user stop pipewire.socket
sleep 2
systemctl --user stop pipewire.service
sleep 1
systemctl --user start pulseaudio.service
systemctl --user start pulseaudio.socket

The output can be set in pulsemixer by pressing F3+Enter
and my HDMI Monitor+Loudspeaker doesn’t grab the sound if I plug it.

1 Like

You could turn of the whole HDMI audio output node. I did the same for my (desktop) GPU.

https://wiki.archlinux.org/title/WirePlumber#Disable_a_device/node

2 Likes

Thanks you. I would not switch to pulseaudio, but if nothing works I will do this.

I am trying to do this, but for some reason it does not work.

The file was created at ~/.config/wireplumber/wireplumber.conf.d/51-alsa-disable.conf with the following content:

monitor.nodes.rules = [
  {
    matches = [
      {
        node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink"
      }
    ]
    actions = {
      update-props = {
        device.disabled = true
      }
    }
  },
  {
    matches = [
      {
        node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink"
      }
    ]
    actions = {
      update-props = {
        device.disabled = true
      }
    }
  },
  {
    matches = [
      {
        node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink"
      }
    ]
    actions = {
      update-props = {
        device.disabled = true
      }
    }
  }  
]

My HDMI devices have no device.name field, only node.name.

$ wpctl inspect 45 | grep node.name
  * node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink"

$ wpctl inspect 59 | grep node.name
  * node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink"

$ wpctl inspect 73 | grep node.name
  * node.name = "alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink"

As you can see the node.name in the config is correct, but still it has no effect. I’ve also tried to set node.disabled to true

Just for fun, could you share the whole output of wpctl status and for one of those HDMI sinks?

I think that your current ~/.config/wireplumber/wireplumber.conf.d/51-alsa-disable.conf rule looks correct and I am all out of ideas… But maybe four eyes see more than two :).

1 Like

Here’s the output:

$ wpctl status
PipeWire 'pipewire-0' [1.2.3, linux@nandor, cookie:244537020]
 └─ Clients:
        32. WirePlumber                         [1.2.3, linux@nandor, pid:1522]
        33. pipewire                            [1.2.3, linux@nandor, pid:1523]
        46. WirePlumber [export]                [1.2.3, linux@nandor, pid:1522]
        77. GNOME Volume Control Media Keys     [1.2.3, linux@nandor, pid:1763]
        78. gnome-shell                         [1.2.3, linux@nandor, pid:1663]
        79. GNOME Shell Volume Control          [1.2.3, linux@nandor, pid:1663]
        80. xdg-desktop-portal                  [1.2.3, linux@nandor, pid:2026]
        81. Firefox                             [1.2.3, linux@nandor, pid:2640]
        86. libcanberra                         [1.2.3, linux@nandor, pid:1763]
        99. wpctl                               [1.2.3, linux@nandor, pid:3173]

Audio
 ├─ Devices:
 │      50. sof-hda-dsp                         [alsa]
 │  
 ├─ Sinks:
 │      54. sof-hda-dsp HDMI / DisplayPort 3 Output [vol: 1.00]
 │      67. sof-hda-dsp HDMI / DisplayPort 2 Output [vol: 1.00]
 │  *   69. sof-hda-dsp Speaker                 [vol: 0.46]
 │     101. sof-hda-dsp HDMI / DisplayPort 1 Output [vol: 0.40]
 │  
 ├─ Sources:
 │  *   68. sof-hda-dsp Digital Microphone      [vol: 1.00]
 │     100. sof-hda-dsp Headphones Stereo Microphone [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:

Video
 ├─ Devices:
 │  
 ├─ Sinks:
 │  
 ├─ Sources:
 │  
 ├─ Filters:
 │  
 └─ Streams:

Settings
 └─ Default Configured Devices:
         0. Audio/Sink    alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink

Also the folders doesn’t/didn’t exist at ~/.config/wireplumber and /etc/wireplumber, should they have existed? If yes, then probably it is not loading the custom configs because of that. I manually created the folders at ~/.config.

That’s fine, I also had to create the folders for myself.
Sorry I am still all out of ideas.

I am using KDE and as soon as I created the rule & restarted PC the HDMI output was gone.


And for another rule I am also matching on node.name so I don’t think that that’s the problem either.

# /home/android/.config/wireplumber/wireplumber.conf.d/50-device-rename.conf
monitor.alsa.rules = [
  {
    matches = [
      {
        node.name = "alsa_input.usb-BEHRINGER_UMC202HD_192k-00.HiFi__Mic1__source"
      }
    ]
    actions = {
      update-props = {
        node.nick = "UMC202HD Input 1"
      }
    }
  }
]

Great, it’s like only I’m having all the unique problems :neutral_face:. I will do a clean install and try again.

Another idea after some googling:

What you can try and do is re-configure the node priorities (“priority.session” property of each node) so that the HDMI output has a higher priority than the analog output and the headphones output has higher priority than the HDMI. Then, it should work as expected.


So playing around with priority.session (and lowering it for the HDMI outputs).

This configures the priority of the node when selecting a default node (default sink/source as a link target for streams). Higher priority nodes will be more likely candidates for becoming the default node.

https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/alsa.html#node-properties


I have never done this myself so you are on your own.

1 Like

I tried it, but the values are not updated, it’s like the config is not seen. The funny thing is that the Speaker has higher priority value than any of the HDMIs.

When HDMI is plugged in, my system switches Profiles, the Speakers will be displayed as Headphones… :smiley:

Okay, for some reason it’s working now. I reinstalled the OS, and configured it globally, in the /etc/wireplumber/wireplumber.conf.d/ folder.

I am glad to hear that you found a solution :partying_face:!

1 Like

Thank you for helping me :smiley: . The custom pipewire config is really awesome

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.