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.

95 lines
1.9KB

  1. #!/bin/bash
  2. # Script to bridge/start pulseaudio into JACK mode
  3. INSTALL_PREFIX="X-PREFIX-X"
  4. # ----------------------------------------------
  5. if [ ! -d ~/.pulse ]; then
  6. mkdir -p ~/.pulse
  7. fi
  8. # ----------------------------------------------
  9. PLAY_ONLY="no"
  10. case $1 in
  11. -h|--h|--help)
  12. echo "usage: $0 [command]
  13. -p, --play Playback mode only
  14. -h, --help Show this help menu
  15. --dummy Don't do anything, just create the needed files
  16. NOTE:
  17. When runned with no arguments, pulse2jack will
  18. activate PulseAudio with both playback and record modes.
  19. "
  20. exit
  21. ;;
  22. --dummy)
  23. exit
  24. ;;
  25. -p|--p|--play)
  26. PLAY_ONLY="yes"
  27. FILE=$INSTALL_PREFIX/share/cadence/pulse2jack/play.pa
  28. ;;
  29. *)
  30. FILE=$INSTALL_PREFIX/share/cadence/pulse2jack/play+rec.pa
  31. ;;
  32. esac
  33. # ----------------------------------------------
  34. IsPulseAudioRunning()
  35. {
  36. PROCESS=`ps -u $USER | grep pulseaudio`
  37. if [ "$PROCESS" == "" ]; then
  38. false
  39. else
  40. true
  41. fi
  42. }
  43. if (IsPulseAudioRunning); then
  44. {
  45. if (`jack_lsp | grep "PulseAudio JACK Sink:" > /dev/null`); then
  46. {
  47. echo "PulseAudio is already running and bridged to JACK"
  48. }
  49. else
  50. {
  51. echo "PulseAudio is already running, bridge it..."
  52. if [ "$PLAY_ONLY" == "yes" ]; then
  53. {
  54. pactl load-module module-jack-sink > /dev/null
  55. pacmd set-default-source jack_in > /dev/null
  56. }
  57. else
  58. {
  59. pactl load-module module-jack-sink > /dev/null
  60. pactl load-module module-jack-source > /dev/null
  61. pacmd set-default-sink jack_out > /dev/null
  62. pacmd set-default-source jack_in > /dev/null
  63. }
  64. fi
  65. echo "Done"
  66. }
  67. fi
  68. }
  69. else
  70. {
  71. if (`pulseaudio --daemonize=no --log-target=journal`); then
  72. echo "Initiated PulseAudio successfully!"
  73. else
  74. echo "Failed to initialize PulseAudio!"
  75. fi
  76. }
  77. fi