check-umc.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if systemctl --user is-active --quiet sooperlooper.service && pw-link -i | grep -Fqx 'sooperlooper:loop0_in_4'; then
  40. links=$(pw-link -l 2>/dev/null) || links=''
  41. if ! printf '%s\n' "$links" |
  42. grep -Fq '|-> sooperlooper:loop0_in_1'; then
  43. echo "Liens SooperLooper absents : lancement de do-plugs.sh"
  44. bash /home/olimex/config-looper/do-plugs.sh
  45. fi
  46. fi
  47. done