parent
6a11717eb4
commit
7c2ac6abfa
@ -0,0 +1,56 @@
|
|||||||
|
import psutil
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import pystray
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
# Function to check if Chatterino is running
|
||||||
|
def is_chatterino_running():
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
try:
|
||||||
|
if "chatterino.exe" in proc.name():
|
||||||
|
return True
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Function to run Chatterino
|
||||||
|
def run_program(program_path):
|
||||||
|
os.startfile(program_path)
|
||||||
|
# todo: switch over to subprocess
|
||||||
|
# process = subprocess.Popen(program_path, cwd = program_path)
|
||||||
|
|
||||||
|
# Function to display system tray icon
|
||||||
|
def on_quit_callback(icon):
|
||||||
|
icon.stop()
|
||||||
|
|
||||||
|
# Define system tray icon and menu
|
||||||
|
def create_tray_icon():
|
||||||
|
icon_image = Image.open("icon.png")
|
||||||
|
menu = pystray.Menu(
|
||||||
|
pystray.MenuItem(
|
||||||
|
"Quit", on_quit_callback, default=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return pystray.Icon("Chatterino Monitor", icon_image, "Chatterino Monitor", menu)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Yandols' Chatterino Process Monitor Script")
|
||||||
|
|
||||||
|
# Set path to Chatterino
|
||||||
|
program_path = "C:\\Program Files\\Chatterino7\\chatterino.exe"
|
||||||
|
|
||||||
|
# Create system tray icon
|
||||||
|
icon = create_tray_icon()
|
||||||
|
|
||||||
|
# Loop to check if Chatterino is running every 10 minutes
|
||||||
|
while True:
|
||||||
|
if is_chatterino_running():
|
||||||
|
print("Chatterino is running. Rechecking in 10 minutes.")
|
||||||
|
else:
|
||||||
|
print("Chatterino is not running. Starting in 30 seconds...")
|
||||||
|
time.sleep(30)
|
||||||
|
run_program(program_path)
|
||||||
|
time.sleep(1) # wait for system tray icon to initialize
|
||||||
|
time.sleep(600) # wait 10 minutes
|
Loading…
Reference in new issue