Browse Source

add script "via-xephyr.py"

https://git.hammerle.me/fphammerle/prusa-slicer-container-image/commit/0331aedbed305edb1cef33e56a7dc4774b0ce4df
Fabian Peter Hammerle 5 months ago
parent
commit
7c263b17bd
1 changed files with 39 additions and 0 deletions
  1. 39 0
      via-xephyr.py

+ 39 - 0
via-xephyr.py

@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+
+import os
+import pathlib
+import random
+import subprocess
+
+
+def _main():
+    image_id = subprocess.run(
+        [
+            "podman",
+            "build",
+            pathlib.Path(__file__).parent,
+            "--iidfile",
+            "/dev/stdout",
+        ],
+        text=True,
+        stdout=subprocess.PIPE,
+        check=True,
+    ).stdout.rsplit("\n", maxsplit=1)[1]
+    assert image_id.startswith("sha256:"), image_id
+    display_name = ":" + str(random.randint(1, 2**31 - 1))
+    subprocess.Popen(["Xephyr", display_name, "-resizeable"])
+    os.execvpe(
+        "podman",
+        [
+            "podman",
+            "container",
+            "runlabel",
+            "podman-run-x11",
+            image_id,
+        ],
+        os.environ | {"DISPLAY": display_name},
+    )
+
+
+if __name__ == "__main__":
+    _main()