From 9502fa1d31e5ef858fa073a77aa5d2022a447663 Mon Sep 17 00:00:00 2001 From: "Tanner Collin (aider)" Date: Tue, 17 Jun 2025 19:23:37 -0600 Subject: [PATCH] feat: Add kill_vnc function to stop VNC viewer --- main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.py b/main.py index b0cb6e9..805f0e4 100644 --- a/main.py +++ b/main.py @@ -37,6 +37,28 @@ def cast_thunder(): except FileNotFoundError: logging.error(f"Command not found: xtightvncviewer. Please ensure it is installed and in PATH.") +def kill_vnc(): + """Executes the killall command for xtightvncviewer.""" + command = "killall xtightvncviewer" + try: + logging.info(f"Executing command: {command}") + # We don't use check=True here because killall returns a non-zero exit code + # if no processes were killed, which is not necessarily an error in this context. + result = subprocess.run(command, shell=True, capture_output=True, text=True) + if result.returncode == 0: + logging.info("killall command executed successfully. Processes were likely terminated.") + else: + # killall returns 1 if no matching processes were found. + # Other non-zero codes might indicate other errors. + logging.warning(f"killall command finished. Exit code: {result.returncode}. Stderr: {result.stderr.strip()}") + if "no process found" in result.stderr.lower(): + logging.info("No xtightvncviewer processes were found to kill.") + + except FileNotFoundError: + logging.error(f"Command not found: killall. Please ensure it is installed and in PATH.") + except Exception as e: + logging.error(f"An unexpected error occurred while trying to run killall: {e}") + def main(): app.run(debug=DEBUG, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))