Remake to have config be on local device and use floppy ID instead
This commit is contained in:
28
main.py
28
main.py
@@ -2,17 +2,20 @@ import time
|
|||||||
import os
|
import os
|
||||||
import tomllib
|
import tomllib
|
||||||
import psutil
|
import psutil
|
||||||
|
import win32api
|
||||||
|
|
||||||
CONFIG_PATH = "A:\\autorun.toml"
|
|
||||||
|
CONFIG_PATH = os.path.join(os.environ["APPDATA"], "FP26CKOSDGLBIFUMD", "library.toml")
|
||||||
|
|
||||||
disk_in = False
|
disk_in = False
|
||||||
already_launched = False
|
already_launched = False
|
||||||
|
app_info = None
|
||||||
|
|
||||||
|
|
||||||
def run_game(app_type, app):
|
def run_game(app_type, app):
|
||||||
if data["launcher"] == "playnite":
|
if app_type == "playnite":
|
||||||
os.startfile(f"playnite://playnite/start/{app}")
|
os.startfile(f"playnite://playnite/start/{app}")
|
||||||
elif data["launcher"] == "steam":
|
elif app_type == "steam":
|
||||||
os.startfile(f"steam://rungameid/{app}")
|
os.startfile(f"steam://rungameid/{app}")
|
||||||
|
|
||||||
|
|
||||||
@@ -23,22 +26,31 @@ def stop_game(game_process):
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if os.path.exists(CONFIG_PATH):
|
if os.path.exists("A:\\"):
|
||||||
disk_in = True
|
disk_in = True
|
||||||
else:
|
else:
|
||||||
disk_in = False
|
disk_in = False
|
||||||
|
|
||||||
if not already_launched and disk_in:
|
if not already_launched and disk_in:
|
||||||
|
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...")
|
print("Launching...")
|
||||||
with open("A:\\autorun.toml", "rb") as f:
|
app_info = config["disks"][floppy_id]
|
||||||
data = tomllib.load(f)
|
run_game(app_info["app_type"], app_info["app"])
|
||||||
run_game(data["app_type"], data["app"])
|
|
||||||
already_launched = True
|
already_launched = True
|
||||||
print("Launched")
|
print("Launched")
|
||||||
|
else:
|
||||||
|
print("Floppy ID not found in library")
|
||||||
|
|
||||||
if already_launched and not disk_in:
|
if already_launched and not disk_in:
|
||||||
|
if app_info:
|
||||||
print("Quitting...")
|
print("Quitting...")
|
||||||
stop_game(data["process"])
|
stop_game(app_info["process"])
|
||||||
already_launched = False
|
already_launched = False
|
||||||
print("Quit Game")
|
print("Quit Game")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user