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
|
|
|
|
|
|
|
|
2021-09-18 14:38:20 +02:00
|
|
|
def edit(filepath: Path, rootpath: Path = None, env=os.environ):
|
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([
|
|
|
|
"termite",
|
|
|
|
"-e",
|
|
|
|
f"vim --servername tex-vorlesung --remote-silent {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
|