Added print timestamp to console for when the monitor does something.

YandolsZX 2 years ago
parent c676cb31e7
commit 2dcd14dc17
  1. 13
      chatterino_process_monitor.py

@ -5,6 +5,7 @@ import os
import subprocess import subprocess
import pystray import pystray
from PIL import Image from PIL import Image
from datetime import datetime
# Function to check if Chatterino is running # Function to check if Chatterino is running
def is_chatterino_running(): def is_chatterino_running():
@ -19,7 +20,9 @@ def is_chatterino_running():
# Function to run Chatterino # Function to run Chatterino
def run_program(program_path): def run_program(program_path):
subprocess.Popen([program_path], cwd=program_dir) subprocess.Popen([program_path], cwd=program_dir)
print("Started Chatterino.") now = datetime.now()
timenow = now.strftime("%H:%M:%S")
print("[" + timenow + "] Started Chatterino.")
# Function to display system tray icon # Function to display system tray icon
def on_quit_callback(icon): def on_quit_callback(icon):
@ -52,9 +55,13 @@ if __name__ == '__main__':
# Loop to check if Chatterino is running every 10 minutes # Loop to check if Chatterino is running every 10 minutes
while True: while True:
if is_chatterino_running(): if is_chatterino_running():
print("Chatterino is running. Rechecking in 10 minutes.") now = datetime.now()
timenow = now.strftime("%H:%M:%S")
print("[" + timenow + "] Chatterino is running. Rechecking in 10 minutes.")
else: else:
print("Chatterino is not running. Starting in 30 seconds...") now = datetime.now()
timenow = now.strftime("%H:%M:%S")
print("[" + timenow + "] Chatterino is not running. Starting in 30 seconds...")
time.sleep(30) time.sleep(30)
run_program(program_path) run_program(program_path)
time.sleep(1) # wait for system tray icon to initialize time.sleep(1) # wait for system tray icon to initialize

Loading…
Cancel
Save