#!/usr/bin/python from subprocess import * print print """Welcome to jackctl.py! Enter the two numbers you want to connect, separated by a space, then hit return. To see the list again, type 'l'. To disconnect clients type 'd' and then the two clients separated by a space Control-D will end the program """ listp = [] def get_list(): global listp listp = Popen(['jack_lsp',''],stdout=PIPE).communicate()[0].split('\n')[:-1] listp_conn = Popen(['jack_lsp','-c'], stdout=PIPE).communicate()[0].split('\n')[:-1] # for x in range(len(listp)): # print "%s) %s" % (x, listp[x]) for i in listp_conn: if (' ' in i) or ('\t' in i): print " %s) %s" % (listp.index(i.lstrip()), i.lstrip()) else: print "%s) %s" % (listp.index(i), i) print "here's what's connected to jack so far:" get_list() while 1: try: prompt = raw_input('jackctl--> ') if prompt == 'l': get_list() else: ports = prompt.split() if ports[0] == 'd': print "disconnecting specified ports" Popen(['jack_disconnect','%s' % listp[int(ports[1])], '%s' % listp[int(ports[2])]]).communicate() else: if (int(ports[0]) < 4) and (int(ports[1]) < 4): print """you shouldn't try connect either connections that give either feedback or connections that are nonsensical""" else: print "connecting specified ports" Popen(['jack_connect','%s' % listp[int(ports[0])], '%s' % listp[int(ports[1])]]).communicate() except EOFError: print "\nGoodbye!" exit() except: print "nonsense!!!" pass