2021-09-17 09:43:54 +02:00
|
|
|
#! /usr/bin/python3
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
from pathlib import Path
|
2021-09-18 14:16:53 +02:00
|
|
|
import os
|
2021-09-17 09:43:54 +02:00
|
|
|
|
2022-05-01 20:41:26 +02:00
|
|
|
from parse_config import terminal
|
|
|
|
|
2021-09-17 09:43:54 +02:00
|
|
|
|
2021-10-10 20:16:19 +02:00
|
|
|
def edit(filepath: Path, rootpath: Path = None, env=os.environ, servername='tex lecture'):
|
2021-09-18 14:16:53 +02:00
|
|
|
if not rootpath:
|
2021-10-10 19:46:47 +02:00
|
|
|
rootpath = filepath.root
|
2021-09-17 09:43:54 +02:00
|
|
|
subprocess.Popen([
|
2022-05-01 20:41:26 +02:00
|
|
|
terminal(),
|
2021-09-17 09:43:54 +02:00
|
|
|
"-e",
|
2022-05-01 21:05:05 +02:00
|
|
|
f"vim",
|
|
|
|
f"--servername {servername}",
|
|
|
|
f"--remote-silent",
|
|
|
|
f"{str(filepath)}"
|
2021-09-18 14:38:20 +02:00
|
|
|
], env=env, cwd=str(rootpath))
|
2021-10-01 19:08:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
def open_pdf(filepath: Path):
|
|
|
|
result = subprocess.run(
|
|
|
|
['zathura', str(filepath)],
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL
|
|
|
|
)
|
|
|
|
return result.returncode
|
2021-10-11 10:11:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|