DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
862B

  1. #!/bin/bash
  2. # Read FIFO argument from CLI
  3. FIFO=${1}
  4. shift
  5. if [ ! -e "${FIFO}" ]; then
  6. echo "Fifo file ${FIFO} does not exist, cannot run"
  7. exit 1
  8. fi
  9. # Start kdialog with all other arguments and get dbus reference
  10. dbusRef=$(kdialog "$@" 100)
  11. if [ $? -ne 0 ] || [ -z "${dbusRef}" ]; then
  12. echo "Failed to start kdialog"
  13. exit 1
  14. fi
  15. # Setup cancellation point for this script
  16. quitfn() {
  17. qdbus ${dbusRef} close 2>/dev/null
  18. exit 0
  19. }
  20. trap quitfn SIGINT
  21. trap quitfn SIGTERM
  22. # Read Fifo for new values or a quit message
  23. while read -t 5 line < "${FIFO}"; do
  24. if [ $? != 0 ]; then
  25. echo "Timed out, closing"
  26. break
  27. fi
  28. if echo "${line}" | grep -q "idle"; then
  29. continue
  30. fi
  31. if echo "${line}" | grep -q "quit"; then
  32. break
  33. fi
  34. if ! qdbus ${dbusRef} Set "" value "${line}"; then
  35. break
  36. fi
  37. done
  38. # Cleanup
  39. rm -f "${FIFO}"
  40. quitfn