Skip to content

Instantly share code, notes, and snippets.

@docPhil99
Created December 23, 2023 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docPhil99/1ddf3b9110a6c9d835b93f287aa23a13 to your computer and use it in GitHub Desktop.
Save docPhil99/1ddf3b9110a6c9d835b93f287aa23a13 to your computer and use it in GitHub Desktop.
Renaming USB sound card

My USB speakers seem to have some buggy firmware in that the device name has been corrupted with some binary. At first I thought it was unicode, but uni2ascii said overwise. Since I need to be able to type the name into config files I had to rename the device using udev.

First we need to fine the name of the device. Run udevadm monitor --kernel --subsystem-match=sound

Unplug and re-plug in the DAC, this results in:


KERNEL[1585.716702] remove   /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1/controlC1 (sound)
KERNEL[1585.716973] remove   /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1/pcmC1D0p (sound)
KERNEL[1585.717031] remove   /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1 (sound)
KERNEL[1589.732577] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1 (sound)
KERNEL[1589.732978] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1/pcmC1D0p (sound)
KERNEL[1589.733183] add      /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1/controlC1 (sound)
KERNEL[1590.091680] change   /devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card1 (sound)

Create a new udev rule /lib/udev/rules.d/85-my_usb-audio.rules

SUBSYSTEM!="sound", GOTO="my_usb_audio_end"
ACTION!="add", GOTO="my_usb_audio_end"
DEVPATH=="/devices/pci0000:00/0000:00:12.0/usb4/4-5/4-5:1.0/sound/card?", ATTR{id}="MyDAC"
LABEL="my_usb_audio_end"

note the question mark on /card? so that it doesn't matter which number the OS uses. ATTR{id} is the name I want call my DAC.

Reboot and enjoy! Test it works by listing the audio devices with aplay -L

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment