Add/update one to many links for link-virtual-mic
This commit is contained in:
parent
5f468b232b
commit
09edab32fa
@ -4,13 +4,14 @@ import subprocess
|
||||
import time
|
||||
|
||||
mappingMic = {
|
||||
"output\\.rnnoise_source:capture_1": "mixed-mic:input_FL",
|
||||
"output\\.rnnoise_source:capture_2": "mixed-mic:input_FR"
|
||||
# "output\\.rnnoise_source:capture_1": ["mixed-mic:input_FL"],
|
||||
# "output\\.rnnoise_source:capture_2": ["mixed-mic:input_FR"]
|
||||
"rnnoise_source:capture_1": ["mixed-mic:input_FL", "mixed-mic:input_FR"],
|
||||
}
|
||||
|
||||
mappingLoopback = {
|
||||
"loopback:monitor_FL": "mixed-mic:input_FL",
|
||||
"loopback:monitor_FR": "mixed-mic:input_FR"
|
||||
"loopback:monitor_FL": ["mixed-mic:input_FL"],
|
||||
"loopback:monitor_FR": ["mixed-mic:input_FR"]
|
||||
}
|
||||
|
||||
|
||||
@ -49,27 +50,30 @@ def main():
|
||||
|
||||
|
||||
def manageLinks(mapping, disconnect=False):
|
||||
for key, value in mapping.items():
|
||||
for iter_out, iter_inputs in mapping.items():
|
||||
cmdOpts = {"shell": True, "capture_output": True, "text": True}
|
||||
|
||||
cmd = "pw-link -o | grep -e '{}'".format(key)
|
||||
cmd = "pw-link -o | grep -e '{}'".format(iter_out)
|
||||
completedProcess = subprocess.run(cmd, **cmdOpts)
|
||||
if completedProcess.returncode == 1:
|
||||
print(f"Output `{iter_out}` not found")
|
||||
return False
|
||||
output = completedProcess.stdout.split('\n')[0]
|
||||
|
||||
cmd = "pw-link -i | grep -e '{}'".format(value)
|
||||
completedProcess = subprocess.run(cmd, **cmdOpts)
|
||||
if completedProcess.returncode == 1:
|
||||
return False
|
||||
input = completedProcess.stdout.split('\n')[0]
|
||||
for iter_input in iter_inputs:
|
||||
cmd = "pw-link -i | grep -e '{}'".format(iter_input)
|
||||
completedProcess = subprocess.run(cmd, **cmdOpts)
|
||||
if completedProcess.returncode == 1:
|
||||
print(f"Output `{iter_input}` not found")
|
||||
return False
|
||||
input = completedProcess.stdout.split('\n')[0]
|
||||
|
||||
if disconnect:
|
||||
cmd = ["pw-link", "-d", output, input]
|
||||
else:
|
||||
cmd = ["pw-link", output, input]
|
||||
print(' '.join(cmd))
|
||||
subprocess.run(cmd, capture_output=True)
|
||||
if disconnect:
|
||||
cmd = ["pw-link", "-d", output, input]
|
||||
else:
|
||||
cmd = ["pw-link", output, input]
|
||||
print(' '.join(cmd))
|
||||
subprocess.run(cmd, capture_output=True)
|
||||
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user