Skip to content

Conversation

@qdeslandes
Copy link
Contributor

When mkosi creates a new console with systemd-pty-forward, it sets a custom (dark) color, which might not play nice depending on your terminal theme.

Introduce the WithConsoleBackground= [Runtime] option to disable with behaviour. Custom console background is enabled by default, so the current behaviour is not modified.

@behrmann
Copy link
Contributor

I agree this would be useful, but mkosi is not the right place to fix this, but this should preferably go into systemd-pty-forward. systemd-run and friends already take an environment variable SYSTEMD_RUN_SHELL_PROMPT_PREFIX, so something like SYSTEMD_PTY_FORWARD_BGCOLOR would make sense, which we could then check for and not set our own colours.

@DaanDeMeyer
Copy link
Contributor

systemd/systemd#39382 will do the trick by allowing you to set the SYSTEMD_TINT_BACKGROUND=0 environment variable globally to disable color tinting.

@DaanDeMeyer
Copy link
Contributor

DaanDeMeyer commented Oct 20, 2025

We can just check the same environment variables in mkosi, so check for $SYSTEMD_TINT_BACKGROUND and $SYSTEMD_ADJUST_TERMINAL_TITLE in config.environment and os.environ. If both are not set we can skip using systemd-pty-forward completely.

@qdeslandes
Copy link
Contributor Author

I've modified the logic to check apply --background if SYSTEMD_TINT_BACKGROUND is not 0 in mkosi's environment variable or the global environment variables. Same for --title.

systemd-pty-forward is still used if both the custom title and custom background are disabled as the --read-only flag is passed in some cases, it makes the logic simpler to use it by default.

@qdeslandes qdeslandes force-pushed the no_console_bg branch 2 times, most recently from 2b6f5d5 to 9d2d44b Compare October 23, 2025 13:32
When mkosi creates a new console with systemd-pty-forward, it sets a
custom (dark) color, which might not play nice depending on your
terminal theme. Environment variables SYSTEMD_TINT_BACKGROUND and
SYSTEMD_ADJUST_TERMINAL_TITLE allow the user the customize this behaviour, but
they were ignored until a recent change in systemd (c.f. 9c3359f).

Modify mkosi behaviour to respect SYSTEMD_TINT_BACKGROUND and
SYSTEMD_ADJUST_TERMINAL_TITLE when calling systemd-pty-forward.
@DaanDeMeyer DaanDeMeyer merged commit 8fe5df4 into systemd:main Oct 26, 2025
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants