17

I'm running Ubuntu 10.10 on my laptop using an external monitor. The monitor is connected by a HDMI cable. The external monitor does not have boxes, it does have an audio exit for a headphone/.. .

Now when I plug in my external monitor, I want to keep using my laptops boxes. Now it automatically sends the sound through the HDMI port instead.

I can easily change the appropriate settings in the sound configuration menu: I go to hardware and can select the device I want to use: Analog Surround 4.0 Output, instead of the HDMI one. This works and I can hear sound through my laptop boxes.

But I have to change this setting every time again when I plug in my external monitor, when I wake my laptop from the suspended state, etc.

How can I make this the default setting, without having to reset it all the time?

Thanks!

2 Answers2

13

Ubuntu 10.10 is somehow not really up-to-date which makes it a bit hard to confirm the default pulseaudio installation there. However it may be worth to see if you have the module-switch-on-port-available loaded.

In case it is there, then try to disable it by commenting out (#) the following line in your /etc/pulse/default.pa:

# load-module module-switch-on-port-available

After the next restart of the pulseaudio server (e.g. with pulseaudio -k in a terminal) we should no longer switch to a different audio port when this becomes available (e.g. by plugging in your HDMI cable).

Takkat
  • 142,284
  • 2
    Ok thanks @Takkat that's exactly what I was looking for! – user1254962 Dec 13 '12 at 13:23
  • 3
    Five years later this is still relevant for Ubuntu 17.10 with Gnome (thanks). – Sander Verhagen Jan 28 '18 at 08:01
  • 1
    @Takkat I am on 18.04 w Gnome and mine switches from S/PDIF to HDMI, between uses, and between reboots. e.g I will watch youtube, then close the tab, come back later to watch another you tube and it is back on HDMI again. It could be swapping because my screen is going into locked state and I am having to login again but that still that is not good enough reason.

    I prefer the HDMI option but I want it to stay on my selection and not change randomly. I want to be able to, either set the default, or prevent it from switching.

    Can someone expand on this answer for a little more insight?

    – TheArchitecta Feb 08 '19 at 04:43
  • 1
    @NZDev You can try with defining a fallback device with pavucontrol. You may also try to remove conflicting user settings. – Takkat Feb 08 '19 at 07:42
  • 1
    Was trying to get this to work for me, but I think my use case is only slightly different: I rarely plug/unplug my HDMI cable. Often: I turn on and off my bluetooth headphones. I want the audio to switch to bluetooth. But when I turn off my bluetooth (or it runs out of battery), I want it to plug into the speakers: never HDMI. I never have speakers on HDMI. I'd much rather tell Ubuntu never to use those or pick them as default. – macetw Apr 17 '21 at 00:21
2

I have an external monitor connected to my laptop through DisplayPort, and faced this problem in Ubuntu 22.04. Here is how I resolved it

  1. Open pavucontrol and go to Configuration tab.
  2. Change the profile of the HDMI/DisplayPort card* to "Off".
  3. Press the lock icon on right side of card to lock the profile.

enter image description here

This profile will now persist through suspend and addition of HDMI/DisplayPort devices.

*To find which audio card sends output to HDMI/DisplayPort, use the command pacmd list-cards. The card will have 'HDMI' or 'DisplayPort' listed in its list of ports.

Some other ways that I tried:

  1. Disable module-switch-on-port-available as told in the above answer. It works, but a side effect of it is that audio won't be automatically routed to the earphone jack when I plug it in. Need to manually change the setting in pavucontrol. Bluetooth earphones are unaffected by this since it uses a different card.

  2. Setting card profile in ~/.config/pulse/default.pa: set-card-profile alsa_card.pci-0000_07_00.1 off. You can find the symbolic name of a card and its profile using pacmd list-cards. This survived through suspend, but I get error when the card can't be found (when no external display is connected).

  3. Setting a default sink in ~/.config/pulse/default.pa: set-default-sink laptop-speaker-sink-name-here. Nope, didn't work at all.

mrpandey
  • 173