I am writing a short script that will loop through the pdf files in a directory, open them iteratively and let me classify them. The code I've written almost does everything I want. It loops through the files and opens and closes them. Note I'm working on Linux.
However, the cursor is not always staying on the shell, and I don't want to have to keep pressing Alt-tab. Does anyone know a way to use subprocess to run system commands, but to never move away from the shell when Python is running?
A simplified version of what I've got so far:
import signal
import os
import subprocess
import glob
files = glob.glob("pdfs/*.pdf", recursive=True)
for ff in files:
# get the evince call
command = f"evince --fullscreen {ff}"
# open the pdf
process_cat = subprocess.Popen(command, stdout = subprocess.PIPE, shell = True)
next = input("Keep viewing files? Y/N")
# close the pdf
os.kill(process_cat.pid, signal.SIGKILL)
if next != "Y":
break