Collection of tools useful for audio production
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.

86 lines
1.7KB

  1. #!/bin/bash
  2. # Script to stop current pulseaudio and restart it in JACK mode
  3. INSTALL_PREFIX="X-PREFIX-X"
  4. IsPulseAudioRunning()
  5. {
  6. PROCESS=`ps -e | grep pulseaudio`
  7. if [ "$PROCESS" == "" ]; then
  8. false
  9. else
  10. true
  11. fi
  12. }
  13. if [ ! -d ~/.pulse ]; then
  14. mkdir -p ~/.pulse
  15. fi
  16. if [ ! -f ~/.pulse/client.conf ]; then
  17. echo "autospawn = no" > ~/.pulse/client.conf
  18. else
  19. if (! cat ~/.pulse/client.conf | grep "autospawn = no" > /dev/null); then
  20. sed -i '/autospawn =/d' ~/.pulse/client.conf
  21. echo "autospawn = no" >> ~/.pulse/client.conf
  22. fi
  23. fi
  24. if [ ! -f ~/.pulse/daemon.conf ]; then
  25. echo "rlimit-rttime = -1" > ~/.pulse/daemon.conf
  26. else
  27. if (! cat ~/.pulse/daemon.conf | grep "rlimit-rttime = -1" > /dev/null); then
  28. sed -i '/rlimit-rttime =/d' ~/.pulse/daemon.conf
  29. echo "rlimit-rttime = -1" >> ~/.pulse/daemon.conf
  30. fi
  31. fi
  32. case $1 in
  33. -h|--h|--help)
  34. echo "usage: $0 [command]
  35. -p, --play Playback mode only
  36. -h, --help Show this help menu
  37. NOTE:
  38. When runned with no arguments, pulse2jack will
  39. activate PulseAudio with both playback and record modes.
  40. "
  41. exit
  42. ;;
  43. -p|--p|--play)
  44. FILE=$INSTALL_PREFIX/share/cadence/pulse2jack/play.pa
  45. ;;
  46. *)
  47. FILE=$INSTALL_PREFIX/share/cadence/pulse2jack/play+rec.pa
  48. ;;
  49. esac
  50. if (IsPulseAudioRunning); then
  51. {
  52. echo "PulseAudio is running, stopping it..."
  53. killall pulseaudio
  54. env sleep 0.2
  55. if (IsPulseAudioRunning); then
  56. {
  57. echo "Failed, force kill..."
  58. pkill -KILL pulseaudio
  59. env sleep 0.2
  60. }
  61. else
  62. echo "Success!"
  63. fi
  64. }
  65. fi
  66. if (`pulseaudio --daemonize --high-priority --realtime --disallow-module-loading --exit-idle-time=-1 --file=$FILE -n`); then
  67. echo "Initiated PulseAudio successfully!"
  68. else
  69. echo "Failed to initialize PulseAudio!"
  70. fi