For Ubuntu 24.04 (using Pipewire)
The previous answer I'd written stopped working when I updated to 24.04, because Pipewire is now used instead of PulseAudio. It took a bit of digging, but it turns out a similar outcome can be achieved (original source).
Ubuntu 24.04 uses Wireplumber v0.4.17, which uses a Lua config file format. Apparently from Wireplumber v0.5.0 onwards a JSON format is used, so this guide probably won't work e.g. for Ubuntu 24.10.
1. Find audio device name
Run wpctl status to list all Pipewire devices. For me this produces a list like this:
Audio
├─ Devices:
│ 36. USB Audio [alsa]
│ 52. Razer Kiyo X [alsa]
│ 75. Tiger Lake-LP Smart Sound Technology Audio Controller [alsa]
│ 122. Jabra SPEAK 510 [alsa]
│
├─ Sinks:
│ * 40. Jabra SPEAK 510 Analog Stereo [vol: 0.66]
│ 45. Tiger Lake-LP Smart Sound Technology Audio Controller HDMI / DisplayPort 2 Output [vol: 1.00]
│ 64. Tiger Lake-LP Smart Sound Technology Audio Controller HDMI / DisplayPort 3 Output [vol: 1.00]
│ 70. Tiger Lake-LP Smart Sound Technology Audio Controller HDMI / DisplayPort 1 Output [vol: 0.40]
│ 88. USB Audio Line Out [vol: 0.40]
│ 120. USB Audio Headphones [vol: 0.40]
│ 125. Tiger Lake-LP Smart Sound Technology Audio Controller Speaker + Headphones [vol: 0.40]
│
├─ Sink endpoints:
│
├─ Sources:
│ 46. USB Audio Headset Microphone [vol: 1.00]
│ 54. Razer Kiyo X Analog Stereo [vol: 1.00]
│ * 66. Jabra SPEAK 510 Mono [vol: 1.00]
│ 119. Tiger Lake-LP Smart Sound Technology Audio Controller Headset Mono Microphone + Headphones Stereo Microphone [vol: 1.00]
│ 129. Tiger Lake-LP Smart Sound Technology Audio Controller Digital Microphone [vol: 1.00]
│
├─ Source endpoints:
│
└─ Streams:
The Dell dock unhelpfully just shows up as "USB Audio", it might take some trial-and-error to find the correct device.
Now inspect the device using the ID from the previous output, e.g. for me this was wpctl inspect 36:
$ wpctl inspect 36
id 36, type PipeWire:Interface:Device
alsa.card = "3"
alsa.card_name = "WD19 Dock"
alsa.components = "USB0bda:402e"
alsa.driver_name = "snd_usb_audio"
alsa.id = "Dock"
alsa.long_card_name = "Dell-WD15-Dock"
alsa.mixer_name = "USB Mixer"
api.acp.auto-port = "false"
api.acp.auto-profile = "false"
api.alsa.card = "3"
api.alsa.card.longname = "Dell-WD15-Dock"
api.alsa.card.name = "WD19 Dock"
api.alsa.path = "hw:3"
api.alsa.use-acp = "true"
api.dbus.ReserveDevice1 = "Audio3"
* client.id = "67"
* device.api = "alsa"
device.bus = "usb"
device.bus-id = "usb-Generic_USB_Audio_200901010001-00"
device.bus-path = "pci-0000:00:14.0-usb-0:8.3.4:1.0"
* device.description = "USB Audio"
device.enum.api = "udev"
device.icon-name = "audio-card-analog-usb"
* device.name = "alsa_card.usb-Generic_USB_Audio_200901010001-00"
* device.nick = "WD19 Dock"
device.plugged.usec = "2174818962"
device.product.id = "0x402e"
device.product.name = "USB Audio"
device.profile-set = "dell-dock-tb16-usb-audio.conf"
device.serial = "Generic_USB_Audio_200901010001"
device.string = "3"
device.subsystem = "sound"
device.sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8.3/3-8.3.4/3-8.3.4:1.0/sound/card3"
device.vendor.id = "0x0bda"
device.vendor.name = "Realtek Semiconductor Corp."
* factory.id = "14"
* media.class = "Audio/Device"
object.path = "alsa:pcm:3"
* object.serial = "1488"
We're looking for the line device.name = "alsa_card.usb-Generic_USB_Audio_200901010001-00"
2. Create Lua config rule
The Wireplumber config directory probably won't exist yet, so first create it with mkdir -p ~/.config/wireplumber/main.lua.d.
Then create a file at ~/.config/wireplumber/main.lua.d/51-alsa-disable.lua with this contents:
disable_dock = {
matches = {
{
{ "device.name", "equals", "alsa_card.usb-Generic_USB_Audio_200901010001-00" },
},
},
apply_properties = {
["device.disabled"] = true,
},
}
table.insert(alsa_monitor.rules,disable_dock)
3. Restart Wireplumber
Run systemctl --user restart wireplumber.service to restart Wireplumber.
The sound device should now be removed from the available devices.
For Ubuntu 22.04 and earlier (using PulseAudio)
I don't have this specific dock, but I have a similar one (the Dell WD19) which also has line-out and headphones sockets. It's frustrating because PulseAudio will automatically switch sound output to the dock headphones output every time I connect the dock, even if there's no headphones connected. If I'm taking a call I'll connect a USB headset, so I have no use for the headphones or line-out ports on the dock. I do quite like having PulseAudio switch automatically to the USB headset though, so I don't want to disable the automatic switching altogether. It's possible to change the active output through the command line, as described in this question, but the automatic switching still goes back to the dock outputs when I disconnect the headset.
It turns out it's not so hard to have PulseAudio ignore a device, through a udev rule. (Original source)
1. Find USB device vendor and product IDs
Run pactl list sinks to see the details of all the audio outputs known to PulseAudio. This will produce quite a lot of output, but it should be easy enough to find the specific device(s) we want to blacklist.
Sink #21
State: RUNNING
Name: alsa_output.usb-Generic_USB_Audio_200901010001-00.HiFi__hw_Dock__sink
Description: USB Audio Headphones
Driver: module-alsa-card.c
Sample Specification: s24le 2ch 48000Hz
Channel Map: front-left,front-right
Owner Module: 37
Mute: no
Volume: front-left: 30419 / 46% / -20.00 dB, front-right: 30419 / 46% / -20.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: alsa_output.usb-Generic_USB_Audio_200901010001-00.HiFi__hw_Dock__sink.monitor
Latency: 21709 usec, configured 18750 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "24"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "USB Audio"
alsa.id = "USB Audio"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "WD19 Dock"
alsa.long_card_name = "Dell-WD15-Dock"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:14.0-usb-0:1.3.4:1.0"
sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4:1.0/sound/card1"
udev.id = "usb-Generic_USB_Audio_200901010001-00"
device.bus = "usb"
device.vendor.id = "0bda"
device.vendor.name = "Realtek Semiconductor Corp."
device.product.id = "402e"
device.product.name = "USB Audio"
device.serial = "Generic_USB_Audio_200901010001"
device.string = "hw:Dock"
device.buffering.buffer_size = "576000"
device.buffering.fragment_size = "288000"
device.access_mode = "mmap+timer"
device.profile.name = "HiFi: hw:Dock: sink"
device.profile.description = "Headphones"
alsa.mixer_device = "hw:Dock"
device.description = "USB Audio Headphones"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-usb"
Ports:
[Out] Headphones: Headphones (priority: 100)
Active Port: [Out] Headphones
Formats:
pcm
We are looking for the lines device.vendor.id = "0bda" and device.product.id = "402e".
2. Create custom udev rule
Create a file /etc/udev/rules.d/89-pulseaudio-usb.rules (with your preferred editor) and insert a line like this, using the vendor and product IDs found before:
ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="402e", ENV{PULSE_IGNORE}="1"
Save the file, then disconnect the dock.
3. Reconnect (restart not needed)
udev should read this new rule and tell PulseAudio to ignore the device the very next time it is connected - a restart shouldn't be necesary (at least I didn't need to on Ubuntu 20.04). The device will no longer show up at all as an output device for PulseAudio, so it won't be chosen automatically as the output device.