Compare commits

...

4 Commits

Author SHA1 Message Date
f814325966 Added lockscreens script 2023-04-19 20:13:20 +01:00
5b02adfa88 Add symlink to link-virtual-mic 2023-04-12 08:20:50 +01:00
2e93b1a285 Fuck bash scripting sometimes
- Rewrote the script in python
2023-04-12 08:19:03 +01:00
964916722c Add script to link pipewire sources/mics 2023-04-12 03:43:17 +01:00
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1 @@
../pipewire/link-virtual-mic

View File

@ -0,0 +1 @@
../sway/lockscreen

View File

@ -0,0 +1,78 @@
#!/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()

View File

@ -0,0 +1,9 @@
#!/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 %%