Compare commits
No commits in common. "f814325966b5c0b83574303c7fd8164e27a5c79d" and "dffd283d4c5f68da74a5d6e7991b6b841253e53e" have entirely different histories.
f814325966
...
dffd283d4c
@ -1 +0,0 @@
|
|||||||
../pipewire/link-virtual-mic
|
|
@ -1 +0,0 @@
|
|||||||
../sway/lockscreen
|
|
@ -1,78 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import argparse
|
|
||||||
import subprocess
|
|
||||||
import time
|
|
||||||
|
|
||||||
mappingMic = {
|
|
||||||
"output\\.rnnoise_source:capture_1": "mixed-mic:input_FL",
|
|
||||||
"output\\.rnnoise_source:capture_2": "mixed-mic:input_FR"
|
|
||||||
}
|
|
||||||
|
|
||||||
mappingLoopback = {
|
|
||||||
"loopback:monitor_FL": "mixed-mic:input_FL",
|
|
||||||
"loopback:monitor_FR": "mixed-mic:input_FR"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
prog="link-virtual-mic",
|
|
||||||
description="link pipewire virtual mics.")
|
|
||||||
|
|
||||||
parser.add_argument("-a", "--all", action="store_true")
|
|
||||||
parser.add_argument("-d", "--disconnect", action="store_true")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
connectAll = args.all and not args.disconnect
|
|
||||||
disconnectAll = args.all and args.disconnect
|
|
||||||
|
|
||||||
disconnectMic = args.all and args.disconnect
|
|
||||||
disconnectLoopback = args.disconnect
|
|
||||||
|
|
||||||
tries = -1
|
|
||||||
while tries < 20:
|
|
||||||
tries += 1
|
|
||||||
|
|
||||||
micSuccess = True
|
|
||||||
loopbackSuccess = True
|
|
||||||
if disconnectAll or not args.disconnect:
|
|
||||||
micSuccess = manageLinks(mappingMic, disconnectMic)
|
|
||||||
if connectAll or disconnectLoopback:
|
|
||||||
loopbackSuccess = manageLinks(mappingLoopback, disconnectLoopback)
|
|
||||||
|
|
||||||
if not micSuccess or not loopbackSuccess:
|
|
||||||
time.sleep(1)
|
|
||||||
continue
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
def manageLinks(mapping, disconnect=False):
|
|
||||||
for key, value in mapping.items():
|
|
||||||
cmdOpts = {"shell": True, "capture_output": True, "text": True}
|
|
||||||
|
|
||||||
cmd = "pw-link -o | grep -e '{}'".format(key)
|
|
||||||
completedProcess = subprocess.run(cmd, **cmdOpts)
|
|
||||||
if completedProcess.returncode == 1:
|
|
||||||
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]
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Times the screen off and puts it to background
|
|
||||||
swayidle \
|
|
||||||
timeout 1 'swaymsg "output * dpms off"' \
|
|
||||||
resume 'swaymsg "output * dpms on"' &
|
|
||||||
# Locks the screen immediately
|
|
||||||
swaylock -c 000000
|
|
||||||
# Kills last background task so idle timer doesn't keep running
|
|
||||||
kill %%
|
|
Loading…
Reference in New Issue
Block a user