Hey I tried the following:
make / writable.
check Vendor ID and Product ID with after you have plugged in the USB DAC :
dmesg | grep Vendor
for me
=>
"New USB device found, idVendor=05ac, idProduct=110a, bcdDevice=26.50"
(it is a: Apple, Inc. USB-C to 3.5mm Headphone Jack Adapter)
(for another product with another Vendor and Product ID icould also get another DAC work)
in cd /etc/udev/rules.d create:
# USB-DAC plug in
ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="110a", ACTION=="add", RUN+="/usr/local/bin/load_dac_module.sh"
# USB-DAC unplug
ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="110a", ACTION=="remove", RUN+="/usr/local/bin/unload_dac_module.sh"
reload udev rules:
sudo systemctl daemon-reload
sudo udevadm trigger
check aplay -l
for me:
=>
card 1 and Device 0
in /usr/local/bin/ create the scripts:
1.
/usr/local/bin/load_dac_module.sh
#!/bin/bash
sleep 1
sudo -u phablet pactl --server "unix:/run/user/32011/pulse/native" load-module module-alsa-sink device=hw:1,0
/usr/local/bin/unload_dac_module.sh
#!/bin/bash
# search for loaded module
sleep 1
USER="phablet"
#USERID from phablet= "32011
PULSE_SERVER="unix:/run/user/32011/pulse/native"
MODULE_ID=$(sudo -u $USER pactl --server "$PULSE_SERVER" list short modules | grep module-alsa-sink | awk '{print $1}' )
# unload PulseAudio-Module , if it was loaded before
if [ -n "$MODULE_ID" ]; then
# pactl unload-module $MODULE_ID
sleep 1
sudo -u phablet pactl --server "unix:/run/user/32011/pulse/native" unload-module $MODULE_ID
fi
make the files writable:
sudo chmod +x /usr/local/bin/load_dac_module.sh
sudo chmod +x /usr/local/bin/unload_dac_module.sh
unplug USB DAC
reboot
(if the USB DAC was plugged at boot it seem that the DAC does not work than.)
on a FP4 it took nearly 4 sec till the sound comes from the DAC
Could somebody test and verify it?
PS:
this helped me:
https://wiki.archlinux.org/title/PulseAudio/Examples#Automatically_switch_audio_to_HDMI