forked from onlaj/Piano-LED-Visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectall.rb
More file actions
30 lines (28 loc) · 770 Bytes
/
Copy pathconnectall.rb
File metadata and controls
30 lines (28 loc) · 770 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
28
29
30
#!/usr/bin/ruby
t = `aconnect -i -l`
$devices = {}
$device = 0
t.lines.each do |l|
match = /client (\d*)\:((?:(?!client).)*)?/.match(l)
# we skip empty lines and the "Through" port
unless match.nil? || match[1] == '0' || /Through/=~l
$device = match[1]
$devices[$device] = []
end
match = /^\s+(\d+)\s/.match(l)
if !match.nil? && !$devices[$device].nil?
$devices[$device] << match[1]
end
end
$devices.each do |device1, ports1|
ports1.each do |port1|
$devices.each do |device2, ports2|
ports2.each do |port2|
# probably not a good idea to connect a port to itself
unless device1 == device2 && port1 == port2
system "aconnect #{device1}:#{port1} #{device2}:#{port2}"
end
end
end
end
end