university-setup/scripts/window_subprocess.py

42 lines
1 KiB
Python
Raw Normal View History

#! /usr/bin/python3
import subprocess
from pathlib import Path
import os
2022-07-26 20:02:57 +02:00
from config_loader import TERMINAL, EDITOR
2022-05-01 20:41:26 +02:00
2021-10-10 20:16:19 +02:00
def edit(filepath: Path, rootpath: Path = None, env=os.environ, servername='tex lecture'):
if not rootpath:
2021-10-10 19:46:47 +02:00
rootpath = filepath.root
subprocess.Popen([
2022-07-26 20:02:57 +02:00
TERMINAL,
"-e",
2022-07-26 20:02:57 +02:00
EDITOR,
f"--servername {servername}",
f"--remote-silent",
f"{str(filepath)}"
], env=env, cwd=str(rootpath))
def open_pdf(filepath: Path):
result = subprocess.run(
['zathura', str(filepath)],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
return result.returncode
def open_zoom(confno: int, pwd_hash: str = None):
subprocess.Popen(
["zoom",
"zoomtg://zoom.us/join?browser=chrom&confno={confno}&zc=0{pwd}".format(
confno=confno,
pwd='&pwd={}'.format(pwd_hash) if pwd_hash is not None else '')
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)