found a better option
using systemd as described below worked on startup but not when plugging devices in to an already running system.
To ignore audio when hot-plugging and on boot, udev rules are the better option.
Adapted from Tell PulseAudio to ignore a USB device using udev:
use lsusb
to identify the vendor/product id of the device you want to ignore
$ lsusb
Bus 006 Device 003: ID 17e9:4307 DisplayLink LAPDOCK
# <other devices I don't care about>
the ID
part gives us the magic numbers
create a udev rules file, e.g. /etc/udev/rules.d/80-ignore-audio-cards.rules
that sets an environment variable for pulse audio.
For me this looked like:
ATTRS{idVendor}=="17e9", ATTRS{idProduct}=="4307", ENV{PULSE_IGNORE}="1"
I chose the 80-
prefix for the filename arbitrarily. If you any pulseaudio related rules, make sure your new file starts with a lower number
reboot to ensure it takes effect
With the udev rule in place, pulseaudio ignores the device completely.
previous answer:
Ran into the same problem, and the given answers didn't work for me across restarts. I think my issue was delayed detection of cards; when pulseaudio started up it didn't see all the cards, and some combination of module-switch-on-connect
and module-switch-on-port-available
was always resetting my choices.
I solved this by making a systemd user unit to run pactl set_card_profile "$MY_CARD_NAME" off
when I logged in.
find the name of the card you don't want; hopefully the name should be enough to tell which one:
$ pactl list cards | grep -E '(Card|Name:)'
Card #0
Name: alsa_card.usb-DisplayLink_LAPDOCK_U3D2338486250-02
Card #1
Name: alsa_card.pci-0000_01_00.1
Card #2
Name: alsa_card.usb-Plantronics_Plantronics_Blackwire_5220_Series_2961D11C621649939CED8BF57E910BA5-00
Card #3
Name: alsa_card.usb-HD_Web_Camera_HD_Web_Camera_Ucamera001-02
Card #4
Name: alsa_card.pci-0000_00_1f.3
For me, it was the "LAPDOCK" that kept stealing my audio.
create the systemd unit, to call pactl
and disable the card:
$ mkdir -p ~/.config/systemd/user
$ nano ~/.config/systemd/user/disable-cards.service
Add these contents, changing the ExecStart
line to refer to the card you want to drop:
[Unit]
Description=Disable card
[Service]
Type=simple
Restart=on-failure
ExecStart=pactl set-card-profile "alsa_card.usb-DisplayLink_LAPDOCK_U3D2338486250-02" off
[Install]
WantedBy=default.target
enable the service: systemctl --user enable disable-cards
Now when you restart systemd will keep trying to disconnect that card until it succeeds. There's probably better systemd
config to get this running after the monitor is plugged in; each device shows up as a "unit" (e.g. in the output of systemctl --user
) so this could be improved to work as you plug/unplug things.
The other alternative is to change your /etc/pulse/default.pa
to use module-switch-on-connect blacklist="REGEX_MATCHING_THE_CARD_NAME"
, but that didn't work for me; there's no way to customize module-switch-on-port-available
, and I think that's what was selecting it for me.