# HG changeset patch # User František Kučera # Date 1602027963 -7200 # Node ID eebc16b7c3e4a74b8427045566375448b6c6fe71 # Parent 70b252d02a9288b7fb3db37e109281a308f146fc use relpipe-in-jack --list-jack-ports for bash-completion diff -r 70b252d02a92 -r eebc16b7c3e4 bash-completion.sh --- a/bash-completion.sh Tue Oct 06 16:24:57 2020 +0200 +++ b/bash-completion.sh Wed Oct 07 01:46:03 2020 +0200 @@ -13,22 +13,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +_relpipe_out_jack_completion_read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done } + _relpipe_out_jack_completion_ports() { - # TODO: simpler and faster implementation in relpipe-out-jack or relpipe-in-jack C++ code - jack_lsp -tp 2>/dev/null \ - | tr -d \\t \ - | tr \\n \\0 \ - | relpipe-in-cli \ - --relation "jack_midi_port" \ - --attribute "name" string \ - --attribute "properties" string \ - --attribute "type" string \ - --records-on-stdin true \ - | relpipe-tr-grep '.*' 'properties' 'input' \ - | relpipe-tr-grep '.*' 'type' 'midi' \ - | relpipe-tr-cut '.*' 'name' \ - | relpipe-out-nullbyte \ - | tr \\0 \\n + if type relpipe-in-jack &> /dev/null && type relpipe-out-nullbyte &> /dev/null; then + relpipe-in-jack --list-jack-ports true --list-midi-messages false 2>/dev/null \ + | relpipe-out-nullbyte \ + | while _relpipe_out_jack_completion_read_nullbyte "name" "input" "output" "physical" "terminal" "mine" "midi" "type"; do + if [[ "$midi" = "true" && "$input" = "true" && "$mine" = "false" ]]; then echo "$name"; fi; done + fi } _relpipe_out_jack_completion() {