Add/update one to many links for link-virtual-mic

This commit is contained in:
Sheldon Lee 2023-11-28 14:59:53 +08:00
parent 5f468b232b
commit 09edab32fa

View File

@ -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,18 +50,21 @@ 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)
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]