From 921968bec3757b8015bfcca5a6f126734fc2ced2 Mon Sep 17 00:00:00 2001 From: kramo Date: Mon, 20 Mar 2023 19:29:55 +0100 Subject: [PATCH] Properly launch games on Windows --- src/utils/heroic_parser.py | 18 +++++++++++++++--- src/utils/run_command.py | 2 ++ src/utils/steam_parser.py | 6 +++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/utils/heroic_parser.py b/src/utils/heroic_parser.py index 58936bd..68cbe66 100644 --- a/src/utils/heroic_parser.py +++ b/src/utils/heroic_parser.py @@ -129,7 +129,11 @@ def heroic_parser(parent_widget, action): values["name"] = game["title"] values["developer"] = game["developer"] - values["executable"] = "xdg-open heroic://launch/" + app_name + values["executable"] = ( + "start heroic://launch/" + app_name + if os.name == "nt" + else "xdg-open heroic://launch/" + app_name + ) values["hidden"] = False values["source"] = "heroic_epic" values["added"] = current_time @@ -189,7 +193,11 @@ def heroic_parser(parent_widget, action): save_cover(values, parent_widget, image_path) break - values["executable"] = "xdg-open heroic://launch/" + app_name + values["executable"] = ( + "start heroic://launch/" + app_name + if os.name == "nt" + else "xdg-open heroic://launch/" + app_name + ) values["hidden"] = False values["source"] = "heroic_gog" values["added"] = current_time @@ -220,7 +228,11 @@ def heroic_parser(parent_widget, action): continue values["name"] = item["title"] - values["executable"] = "xdg-open heroic://launch/" + app_name + values["executable"] = ( + "start heroic://launch/" + app_name + if os.name == "nt" + else "xdg-open heroic://launch/" + app_name + ) values["hidden"] = False values["source"] = "heroic_sideload" values["added"] = current_time diff --git a/src/utils/run_command.py b/src/utils/run_command.py index 78306b6..25579d2 100644 --- a/src/utils/run_command.py +++ b/src/utils/run_command.py @@ -28,6 +28,8 @@ def run_command(executable): subprocess.Popen( ["flatpak-spawn --host " + executable] if os.getenv("FLATPAK_ID") == "hu.kramo.Cartridges" + else executable.split() + if os.name == "nt" else [executable], shell=True, start_new_session=True, diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index a8f49ab..13c936c 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -63,7 +63,11 @@ def get_game(task, datatypes, current_time, parent_widget, appmanifest, steam_di task.return_value(None) return - values["executable"] = "xdg-open steam://rungameid/" + values["appid"] + values["executable"] = ( + "start steam://rungameid/" + values["appid"] + if os.name == "nt" + else "xdg-open steam://rungameid/" + values["appid"] + ) values["hidden"] = False values["source"] = "steam" values["added"] = current_time