author | František Kučera <franta-hg@frantovo.cz> |
Sat, 04 Dec 2021 21:14:50 +0100 | |
branch | v_0 |
changeset 23 | 0e2ceaef4fd4 |
parent 16 | 79520ded76f0 |
permissions | -rw-r--r-- |
8
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
# Relational pipes |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
# Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
# |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
# This program is free software: you can redistribute it and/or modify |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
# it under the terms of the GNU General Public License as published by |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
# the Free Software Foundation, version 3 of the License. |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
# |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
# This program is distributed in the hope that it will be useful, |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
# GNU General Public License for more details. |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
# |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
# You should have received a copy of the GNU General Public License |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
|
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
16 |
_relpipe_in_jack_completion_read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done } |
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
17 |
|
10
ded44e94147c
add --jack-connect-to-port and --required-jack-connections options
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
18 |
_relpipe_in_jack_completion_ports() { |
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
19 |
if type relpipe-in-jack &> /dev/null && type relpipe-out-nullbyte &> /dev/null; then |
12
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
20 |
relpipe-in-jack --list-ports true --list-midi-messages false 2>/dev/null \ |
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
21 |
| relpipe-out-nullbyte \ |
16
79520ded76f0
fix bash-completion (uuid) + connect/disconnect error message (to/from)
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
22 |
| while _relpipe_in_jack_completion_read_nullbyte "name" "uuid" "input" "output" "physical" "terminal" "mine" "midi" "type"; do |
14
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
23 |
if [[ "$midi" = "true" && "${!1}" = "true" && "$mine" = "false" ]]; then echo "$name"; fi; done |
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
24 |
fi |
10
ded44e94147c
add --jack-connect-to-port and --required-jack-connections options
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
25 |
} |
ded44e94147c
add --jack-connect-to-port and --required-jack-connections options
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
26 |
|
8
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
_relpipe_in_jack_completion() { |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
local w0 w1 w2 w3 |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
COMPREPLY=() |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
w0=${COMP_WORDS[COMP_CWORD]} |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
w1=${COMP_WORDS[COMP_CWORD-1]} |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
w2=${COMP_WORDS[COMP_CWORD-2]} |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
w3=${COMP_WORDS[COMP_CWORD-3]} |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
36 |
BOOLEAN_VALUES=( |
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
37 |
"true" |
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
38 |
"false" |
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
39 |
) |
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
40 |
|
12
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
41 |
if [[ "$w1" == "--client" && "x$w0" == "x" ]]; then COMPREPLY=("'relpipe-in-jack'") |
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
42 |
elif [[ "$w1" == "--port" && "x$w0" == "x" ]]; then COMPREPLY=("'midi-in'") |
14
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
43 |
elif [[ "$w1" == "--connect-to" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports output)" -- "$w0")) |
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
44 |
elif [[ "$w1" == "--connect-ports" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports output)" -- "$w0")) |
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
45 |
elif [[ "$w2" == "--connect-ports" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports input)" -- "$w0")) |
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
46 |
elif [[ "$w1" == "--disconnect-ports" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports output)" -- "$w0")) |
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
47 |
elif [[ "$w2" == "--disconnect-ports" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_in_jack_completion_ports input)" -- "$w0")) |
12
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
48 |
elif [[ "$w1" == "--required-connections" && "x$w0" == "x" ]]; then COMPREPLY=("0") |
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
49 |
elif [[ "$w1" == "--list-ports" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
13
326935d1bfab
add option --list-connections for listing JACK connections
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
50 |
elif [[ "$w1" == "--list-connections" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
15
463ce61415f1
partial support for metadata: --list-properties
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
51 |
elif [[ "$w1" == "--list-properties" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
52 |
elif [[ "$w1" == "--list-midi-messages" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
8
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
else |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
OPTIONS=( |
12
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
55 |
"--client" |
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
56 |
"--port" |
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
57 |
"--connect-to" |
14
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
58 |
"--connect-ports" |
cde9bb07ea0a
add options --connect-ports and --disconnect-ports to allow connecting and disconnecting arbitrary JACK ports
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
59 |
"--disconnect-ports" |
12
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
60 |
"--required-connections" |
e8aae4d42c01
simplify CLI options: --client --connect-to --required-connections --list-ports + add --port
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
61 |
"--list-ports" |
13
326935d1bfab
add option --list-connections for listing JACK connections
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
62 |
"--list-connections" |
15
463ce61415f1
partial support for metadata: --list-properties
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
63 |
"--list-properties" |
11
07247893054e
add options --list-jack-ports and --list-midi-messages useful for bash-completion
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
64 |
"--list-midi-messages" |
8
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
) |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
fi |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
} |
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
|
8ef1980db907
configurable JACK client name
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
complete -F _relpipe_in_jack_completion relpipe-in-jack |