forked from brummer10/pajackconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pajackconnect
executable file
·59 lines (57 loc) · 2.1 KB
/
pajackconnect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#+
# This script is intended to be invoked via QjackCtl to start up and
# shut down JACK on a system running PulseAudio. It handles the
# necessary setup to make the two work together, so PulseAudio clients
# get transparently routed through JACK while the latter is running.
#
# Usage: in QjackCtl’s Settings window, in the “Options” tab, enter
# the command
#
# pajackconnect start
#
# in the field labelled “Execute script after Startup”, and put
#
# pajackconnect stop
#
# in the field labelled “Execute script on Shutdown”.
#
# References:
# PulseAudio: <http://www.freedesktop.org/wiki/Software/PulseAudio/>
# JACK: <http://jackaudio.org/>
#
# Copyright 2014 by Lawrence D'Oliveiro <ldo@geek-central.gen.nz>. This
# script is licensed CC0
# <https://creativecommons.org/publicdomain/zero/1.0/>; do with it
# what you will.
#-
if [ "$#" == 1 ]; then
cmd="$1"
else
cmd=
fi
if [ "$cmd" != "start" -a "$cmd" != "stop" ]; then
echo $'Usage:\n\t'"$0"$' start|stop\n' 1>&2
exit 3
fi
if [ "$cmd" = "start" ]; then
# module-jack-sink and module-jack-source let PulseAudio route
# its inputs and outputs through a running instance of JACK.
# These modules automatically unload when JACK goes away.
# Trivia question: what’s the difference between pacmd and pactl?
pacmd load-module module-jack-sink channels=2
pacmd load-module module-jack-source channels=2
# module-suspend-on-idle kicks in to suspend idle sinks. Unfortunately
# this causes the JACK sink to be suspended, and there seems to be no
# way to resume it. So this module needs to go. It will come back
# after PulseAudio is restarted (on unload, below).
pacmd unload-module module-suspend-on-idle
pacmd set-default-sink jack_out
# Fun fact: if jackd wasn’t running before you used this script, PulseAudio
# seems to automatically start it.
elif [ "$cmd" = "stop" ]; then
killall jackd # for symmetry, in case it was started by PulseAudio
# only way to restore normal operation after JACK quits seems to be to
# force PulseAudio to restart
pulseaudio -k
fi