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-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([
|
|
|
|
"termite",
|
|
|
|
"-e",
|
2021-10-10 20:16:19 +02:00
|
|
|
f"vim --servername {servername} --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
|