7
7
from ctypes import *
8
8
from gogdl.process import Process
9
9
import signal
10
+ import shutil
10
11
import shlex
11
12
12
13
class NoMoreChildren(Exception):
13
14
pass
14
15
16
+ def get_flatpak_command(id: str) -> list[str]:
17
+ if sys.platform != "linux":
18
+ return []
19
+ new_process_command = []
20
+ process_command = ["flatpak", "info", id]
21
+ if os.path.exists("/.flatpak-info"):
22
+ spawn_test = subprocess.run(["flatpak-spawn", "--host" "ls"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
23
+ if spawn_test.returncode == 0:
24
+ new_process_command = ["flatpak-spawn", "--host"]
25
+ process_command = new_process_command + process_command
26
+
27
+ output = subprocess.run(process_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
28
+
29
+ if output.returncode == 0:
30
+ return new_process_command + ["flatpak", "run", id]
31
+ return []
32
+
33
+
15
34
# Supports launching linux builds
16
35
def launch(arguments, unknown_args):
17
36
# print(arguments)
@@ -42,6 +61,7 @@ def launch(arguments, unknown_args):
42
61
if launch_arguments is None:
43
62
launch_arguments = []
44
63
if type(launch_arguments) == str:
64
+ launch_arguments = launch_arguments.replace('\\', '/')
45
65
launch_arguments = shlex.split(launch_arguments)
46
66
if compatibility_flags is None:
47
67
compatibility_flags = []
@@ -57,13 +77,35 @@ def launch(arguments, unknown_args):
57
77
if not os.path.exists(executable):
58
78
executable = get_case_insensitive_name(executable)
59
79
80
+ if sys.platform != "win32" and arguments.platform == 'windows' and not arguments.override_exe:
81
+ if "scummvm.exe" in executable.lower():
82
+ flatpak_scummvm = get_flatpak_command("org.scummvm.ScummVM")
83
+ native_scummvm = shutil.which("scummvm")
84
+ if native_scummvm:
85
+ native_scummvm = [native_scummvm]
86
+
87
+ native_runner = flatpak_scummvm or native_scummvm
88
+ if native_runner:
89
+ wrapper = native_runner
90
+ executable = None
91
+ elif "dosbox.exe" in executable.lower():
92
+ flatpak_dosbox = get_flatpak_command("io.github.dosbox-staging")
93
+ native_dosbox= shutil.which("dosbox")
94
+ if native_dosbox:
95
+ native_dosbox = [native_dosbox]
96
+
97
+ native_runner = flatpak_dosbox or native_dosbox
98
+ if native_runner:
99
+ wrapper = native_runner
100
+ executable = None
101
+
60
102
if len(wrapper) > 0 and wrapper[0] is not None:
61
103
command.extend(wrapper)
62
104
63
105
if arguments.override_exe:
64
106
command.append(arguments.override_exe)
65
107
working_dir = os.path.split(arguments.override_exe)[0]
66
- else :
108
+ elif executable :
67
109
command.append(executable)
68
110
command.extend(launch_arguments)
69
111
else:
0 commit comments