From 8c130dd1b3edfb6e4806a5f61d305d5f8a513be8 Mon Sep 17 00:00:00 2001 From: Owen Feldman Date: Fri, 3 Apr 2026 15:10:20 -0400 Subject: [PATCH] Remake to have config be on local device and use floppy ID instead --- main.py | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index a04db05..502eff1 100644 --- a/main.py +++ b/main.py @@ -2,17 +2,20 @@ import time import os import tomllib import psutil +import win32api -CONFIG_PATH = "A:\\autorun.toml" + +CONFIG_PATH = os.path.join(os.environ["APPDATA"], "FP26CKOSDGLBIFUMD", "library.toml") disk_in = False already_launched = False +app_info = None def run_game(app_type, app): - if data["launcher"] == "playnite": + if app_type == "playnite": os.startfile(f"playnite://playnite/start/{app}") - elif data["launcher"] == "steam": + elif app_type == "steam": os.startfile(f"steam://rungameid/{app}") @@ -23,22 +26,31 @@ def stop_game(game_process): while True: - if os.path.exists(CONFIG_PATH): + if os.path.exists("A:\\"): disk_in = True else: disk_in = False if not already_launched and disk_in: - print("Launching...") - with open("A:\\autorun.toml", "rb") as f: - data = tomllib.load(f) - run_game(data["app_type"], data["app"]) - already_launched = True - print("Launched") + vsn = win32api.GetVolumeInformation("A:\\")[1] + floppy_id = format(vsn, "x") + + with open(CONFIG_PATH, "rb") as f: + config = tomllib.load(f) + + if floppy_id in config["disks"]: + print("Launching...") + app_info = config["disks"][floppy_id] + run_game(app_info["app_type"], app_info["app"]) + already_launched = True + print("Launched") + else: + print("Floppy ID not found in library") if already_launched and not disk_in: - print("Quitting...") - stop_game(data["process"]) - already_launched = False - print("Quit Game") + if app_info: + print("Quitting...") + stop_game(app_info["process"]) + already_launched = False + print("Quit Game") time.sleep(1)