forked from onlaj/Piano-LED-Visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectall.py
More file actions
27 lines (23 loc) · 835 Bytes
/
Copy pathconnectall.py
File metadata and controls
27 lines (23 loc) · 835 Bytes
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
#!/usr/bin/python3
import subprocess
def connectall():
ports = subprocess.check_output(["aconnect", "-i", "-l"], text=True)
port_list = []
client = "0"
for line in str(ports).splitlines():
if line.startswith("client "):
client = line[7:].split(":", 2)[0]
if client == "0" or "Through" in line:
client = "0"
else:
if client == "0" or line.startswith('\t'):
continue
port = line.split()[0]
port_list.append(client + ":" + port)
for source in port_list:
for target in port_list:
if source != target:
# print("aconnect %s %s" % (source, target))
subprocess.call("aconnect %s %s" % (source, target), shell=True)
if __name__ == '__main__':
connectall()