|
1 |
| -"""Auto-connect new JACK ports matching the patterns given on the command line.""" |
| 1 | +"""Auto-connect new JACK ports matching the patterns given on the command line. |
| 2 | +
|
| 3 | +Examples: |
| 4 | +
|
| 5 | +List all JACK input and output ports, including their aliases and pretty names: |
| 6 | +
|
| 7 | + jack-matchmaker -ioan |
| 8 | +
|
| 9 | +List all existing connections between ports, or only those where at least one |
| 10 | +port matches one given PATTERN: |
| 11 | +
|
| 12 | + jack-matchmaker -c [PATTERN, ...] |
| 13 | +
|
| 14 | +Auto-connect the ports 'left' and 'right' of JACK client 'fluidsynth' to the |
| 15 | +system audio playback ports using exact matching mode: |
| 16 | +
|
| 17 | + jack-matchmaker -e fluidsynth:left system:playback_1 fluidsynth:right system:playback_2 |
| 18 | +
|
| 19 | +Auto-connect all ports of client 'mixer' starting with 'l_' to |
| 20 | +'system:playback_1' and all starting with 'r_' to 'system:playback_2': |
| 21 | +
|
| 22 | + jack-matchmaker 'mixer:l_.*' system:playback_1 'mixer:r_.*' system:playback_2 |
| 23 | +
|
| 24 | +Auto-connect ports starting with 'midi' (case-insensitive) of any client to |
| 25 | +'midi-monitor:input': |
| 26 | +
|
| 27 | + jack-matchmaker '(?i).*:midi.*' midi-monitor:input |
| 28 | +
|
| 29 | +Auto-connect system MIDI caspture ports to the respective 'midi_in_track_' |
| 30 | +ports of client 'mydaw' with the corresponding number suffix: |
| 31 | +
|
| 32 | + jack-matchmaker 'system:midi_capture_(?P<num>\d+)$' 'mydaw:midi_in_track_{num}' |
| 33 | +
|
| 34 | +Read port patterns from file 'patterns.txt' and run in verbose mode: |
| 35 | +
|
| 36 | + jack-matchmaker -v -p patterns.txt |
| 37 | +
|
| 38 | +See https://github.com/SpotlightKid/jack-matchmaker for more examples. |
| 39 | +""" |
2 | 40 |
|
3 | 41 | import argparse
|
4 | 42 | import logging
|
@@ -403,7 +441,14 @@ def run(self):
|
403 | 441 |
|
404 | 442 |
|
405 | 443 | def main(args=None):
|
406 |
| - ap = argparse.ArgumentParser(prog=__program__, description=__doc__.splitlines()[0]) |
| 444 | + doclines = __doc__.splitlines() |
| 445 | + ap = argparse.ArgumentParser( |
| 446 | + prog=__program__, |
| 447 | + description=doclines[0], |
| 448 | + epilog="\n".join(doclines[2:]), |
| 449 | + formatter_class=argparse.RawDescriptionHelpFormatter |
| 450 | + ) |
| 451 | + del doclines |
407 | 452 | apg = ap.add_argument_group('actions', 'Listing ports and connections')
|
408 | 453 | apg.add_argument('-c', '--list-connections', dest="actions", action="append_const",
|
409 | 454 | const="list_cnx", help="List all connections between JACK ports "
|
@@ -446,10 +491,14 @@ def main(args=None):
|
446 | 491 |
|
447 | 492 | if args.actions or args.patterns or args.pattern_file:
|
448 | 493 | try:
|
449 |
| - matchmaker = JackMatchmaker(pairwise(args.patterns), args.pattern_file, |
450 |
| - name=args.client_name, exact_matching=args.exact_matching, |
451 |
| - connect_interval=args.connect_interval, |
452 |
| - connect_max_attempts=args.max_attempts) |
| 494 | + matchmaker = JackMatchmaker( |
| 495 | + pairwise(args.patterns), |
| 496 | + args.pattern_file, |
| 497 | + name=args.client_name, |
| 498 | + exact_matching=args.exact_matching, |
| 499 | + connect_interval=args.connect_interval, |
| 500 | + connect_max_attempts=args.max_attempts |
| 501 | + ) |
453 | 502 | except (OSError, RuntimeError) as exc:
|
454 | 503 | return str(exc)
|
455 | 504 | else:
|
@@ -477,6 +526,7 @@ def main(args=None):
|
477 | 526 | log.exception("Startup error")
|
478 | 527 | else:
|
479 | 528 | log.error("Startup error: %s", exc)
|
| 529 | + |
480 | 530 | return str(exc)
|
481 | 531 | finally:
|
482 | 532 | matchmaker.close()
|
|
0 commit comments