custom scripts: app.sh
authorNiki Roo <niki@nikiroo.be>
Fri, 12 Sep 2025 19:01:51 +0000 (21:01 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 12 Sep 2025 19:01:51 +0000 (21:01 +0200)
gamiki/support/commands.py
gamiki/support/custom_commands.py

index 654a925300364b6d9c54846ef87d13c17b874485..56ddf56e0a80aa699d12a5dddc4f67b5d047d522 100644 (file)
@@ -68,25 +68,22 @@ def wine(dir: PurePath, link: PurePath, opt: str = None) -> int:
 
 def qemu(dir: PurePath, link: PurePath, opt: str = None) -> int:
     
-    cmd, env = custom.cmd("qemu", link, None)    
-    if (not cmd):
-        prog = custom.program("qemu")
-        if (prog):
-            cmd = [ prog ]
-        else:
-            raise RuntimeError("qemu not found")
-    
     if (opt):
-        start = dir.joinpath(f"qemu-{opt}.config")
+        qemu_conf = dir.joinpath(f"qemu-{opt}.config")
     else:
-        start = dir.joinpath("qemu.config")
+        qemu_conf = dir.joinpath("qemu.config")
     
-    if (not start.exists()):
+    if (not qemu_conf.exists()):
         return 404;
     
-    # TODO: port qemu.sh in python and use it here
-    cmd = [ "qemu.sh" ];
-    cmd.append(start.as_posix())
+    cmd, env = custom.cmd("qemu", qemu_conf, link)
+    if (not cmd):
+        prog = custom.program("qemu")
+        if (prog):
+            # TODO: port qemu.sh in python?
+            cmd = [ "qemu.sh", qemu_conf.as_posix() ];
+        else:
+            raise RuntimeError("qemu not found")
 
     return run(cmd, cwd=dir, env=env).returncode
 
index 06f57737bba21bf3ad618e864cdd2549ca542885..69b63b055da0e554ec058ee0752d1307aa973358 100644 (file)
@@ -22,34 +22,28 @@ def video(file: PurePath) -> (list, dict):
     return cmd, env
 
 def cmd(prog:str, t:PurePath, lnk:PurePath, pre:PurePath=None) -> (list, dict):
+    # t: the target to start
+    # lnk: link to library directory
+    # pre: the WINEPREFIX (wine only)
     
     cmd = None
     env = environ.copy()
+    
+    # All the custom procedures requires app.sh
+    if (not program("app.sh")):
+        return cmd, env
 
     if (prog == "dosbox"):
-        if (program("app.sh")):
-            cmd = [ 
-                program("app.sh"),"--wait", "dosbox", "--link", t.as_posix()
-            ]
+        cmd = [ program("app.sh"),"--wait", "dosbox", "--ddlink", t.as_posix() ]
     elif (prog == "wine"):
-        if (program("launch.sh")):
-            cmd = [ program("launch.sh"), "wine", "--dlink", t.as_posix() ]
-            lnk_path = lnk.as_posix().replace("'", "\\'")
-            env["OPTS"] = ( ""
-                + "-e WINEPREFIX='" + pre.as_posix().replace("'", "\\'") + "'"
-                + " -v '" + lnk_path + ":" + lnk_path + "'"
-            )
+        cmd = [ 
+           program("app.sh"), "wine", "--ddlink", t.as_posix(), 
+           "--prefix",  pre.as_posix()
+       ]
     elif (prog == "qemu"):
-        if (program("app.sh")):
-            cmd = [ 
-                program("app.sh"),"--wait", "qemu"
-            ]
+        cmd = [ program("app.sh"), "--wait", "qemu",  "--ddlink", t.as_posix() ]
     elif (prog == "start_sh"):
-        if (program("launch.sh")):
-            cmd = [ 
-                program("launch.sh"), "games", "--dlink", t.as_posix()
-            ]
-            env["OPTS"] = "--entrypoint=bash"
+        cmd = [ program("app.sh"), "games", "--dlink", t.as_posix() ]
     
     return cmd, env