check-umc.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. state=""
  3. while :; do
  4. alsa_four=0
  5. for stream in /proc/asound/card*/stream0; do
  6. [ -r "$stream" ] || continue
  7. grep -q '^BEHRINGER UMC404HD' "$stream" || continue
  8. if awk '
  9. /^Capture:/ { capture=1; next }
  10. capture && /Channels: 4/ { found=1 }
  11. END { exit !found }
  12. ' "$stream"; then
  13. alsa_four=1
  14. fi
  15. break
  16. done
  17. if [ "$alsa_four" -ne 1 ]; then
  18. if [ "$state" != "usb" ]; then
  19. echo "UMC absente ou moins de 4 canaux ALSA : pas de redémarrage WirePlumber"
  20. fi
  21. state="usb"
  22. sleep 20
  23. continue
  24. fi
  25. ports=$(pw-link -o 2>/dev/null |
  26. grep -c '^alsa_input\.usb-BEHRINGER_UMC404HD_192k-00\..*:capture_')
  27. if [ "$ports" -ne 4 ]; then
  28. echo "UMC : 4 canaux ALSA, mais $ports ports de capture PipeWire ; redémarrage WirePlumber"
  29. state="pipewire"
  30. systemctl --user restart wireplumber.service
  31. sleep 60
  32. else
  33. if [ "$state" != "ok" ]; then
  34. echo "UMC : 4 canaux de capture disponibles dans PipeWire"
  35. fi
  36. state="ok"
  37. sleep 20
  38. fi
  39. done