From: Daan De Meyer Date: Tue, 28 Oct 2025 14:02:55 +0000 (+0100) Subject: PTY forward fixes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2912ed20d59653531491d150a84d9acef4feac75;p=thirdparty%2Fmkosi.git PTY forward fixes --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 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 83f7d47ff..8f8b98feb 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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("/"): diff --git a/mkosi/config.py b/mkosi/config.py index b572d41f7..6e791f368 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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 diff --git a/mkosi/qemu.py b/mkosi/qemu.py index 63556e340..7f3877bdb 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -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: