Remake to have config be on local device and use floppy ID instead

This commit is contained in:
2026-04-03 15:10:20 -04:00
parent 5add369290
commit 8c130dd1b3

40
main.py
View File

@@ -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)