#!/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()