]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
PTY forward fixes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 Oct 2025 14:02:55 +0000 (15:02 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 28 Oct 2025 19:18:41 +0000 (20:18 +0100)
--title= and the actual title were passed as two separate arguments.
Fix by using --title instead of --title=.

Also only pass arguments if a background or title are provided
respectively.

Also do some general cleanups.

Follow up for 8fe5df44005ce0f8c704f2839a44d988fb7d1ebb

mkosi/__init__.py
mkosi/config.py
mkosi/qemu.py

index 83f7d47ffbc8d76e686044603b06b799b1a0b5c9..8f8b98febb56144daed64f38ee6ea4165c6eb14d 100644 (file)
@@ -4061,7 +4061,7 @@ def run_box(args: Args, config: Config) -> None:
     cmdline = [*args.cmdline]
 
     if sys.stdin.isatty() and sys.stdout.isatty():
-        cmdline = systemd_pty_forward(config, "48;2;12;51;51", "mkosi-sandbox") + cmdline
+        cmdline = systemd_pty_forward(config, background="48;2;12;51;51", title="mkosi-sandbox") + cmdline
 
     with contextlib.ExitStack() as stack:
         if config.tools() != Path("/"):
index b572d41f7c6b3687e2ca444b0ec7b55cf48889c5..6e791f3682998e5f5587a8b1d0d0498963638463 100644 (file)
@@ -6038,7 +6038,12 @@ def systemd_tool_version(*tool: PathString, sandbox: SandboxProtocol = nosandbox
     return version
 
 
-def systemd_pty_forward(config: Config, background: str, title: str) -> list[str]:
+def systemd_pty_forward(
+    config: Config,
+    *,
+    background: Optional[str] = None,
+    title: Optional[str] = None,
+) -> list[str]:
     tint_bg = parse_boolean(config.environment.get("SYSTEMD_TINT_BACKGROUND", "1")) and parse_boolean(
         os.environ.get("SYSTEMD_TINT_BACKGROUND", "1")
     )
@@ -6052,8 +6057,8 @@ def systemd_pty_forward(config: Config, background: str, title: str) -> list[str
         return []
 
     cmd = ["systemd-pty-forward"]
-    if tint_bg:
-        cmd += [f"--background={background}"]
-    if adjust_title:
-        cmd += ["--title=", title]
+    if tint_bg and background:
+        cmd += ["--background", background]
+    if adjust_title and title:
+        cmd += ["--title", title]
     return cmd
index 63556e340c96ea2bce5138b77563712559a4632b..7f3877bdb93529ddd48d7403a924dff746ecb3dc 100644 (file)
@@ -1186,7 +1186,9 @@ def run_qemu(args: Args, config: Config) -> None:
 
     if config.console in (ConsoleMode.interactive, ConsoleMode.read_only):
         cmdline += systemd_pty_forward(
-            config, "48;2;12;51;19", f"Virtual Machine {config.machine_or_name()}"
+            config,
+            background="48;2;12;51;19",
+            title=f"Virtual Machine {config.machine_or_name()}",
         )
 
         if config.console == ConsoleMode.read_only: