From: Lennart Poettering Date: Thu, 11 Sep 2025 09:25:00 +0000 (+0200) Subject: firstboot: show blue "chrome" bar at top X-Git-Tag: v259-rc1~451^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73ee723aa77bfb9f9988b80228b646d65d1770b2;p=thirdparty%2Fsystemd.git firstboot: show blue "chrome" bar at top --- diff --git a/man/systemd-firstboot.xml b/man/systemd-firstboot.xml index 2af354f872c..449fe4ec4a0 100644 --- a/man/systemd-firstboot.xml +++ b/man/systemd-firstboot.xml @@ -344,6 +344,16 @@ + + + + Takes a boolean argument. By default the initial setup scren will show reverse color + "chrome" bars at the top and and the bottom of the terminal screen, which may be disabled by setting + this option to false. + + + + diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index e311cb9fa7d..b7b09ba8752 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -85,6 +85,7 @@ static bool arg_root_password_is_hashed = false; static bool arg_welcome = true; static bool arg_reset = false; static ImagePolicy *arg_image_policy = NULL; +static bool arg_chrome = true; STATIC_DESTRUCTOR_REGISTER(arg_root, freep); STATIC_DESTRUCTOR_REGISTER(arg_image, freep); @@ -114,6 +115,11 @@ static void print_welcome(int rfd) { return; } + (void) terminal_reset_defensive_locked(STDOUT_FILENO, /* flags= */ 0); + + if (arg_chrome) + chrome_show("Initial Setup", /* bottom= */ NULL); + r = parse_os_release_at(rfd, "PRETTY_NAME", &pretty_name, "NAME", &os_name, @@ -125,13 +131,10 @@ static void print_welcome(int rfd) { pn = os_release_pretty_name(pretty_name, os_name); ac = isempty(ansi_color) ? "0" : ansi_color; - (void) terminal_reset_defensive_locked(STDOUT_FILENO, /* flags= */ 0); - if (colors_enabled()) - printf("\n" - ANSI_HIGHLIGHT "Welcome to your new installation of " ANSI_NORMAL "\x1B[%sm%s" ANSI_HIGHLIGHT "!" ANSI_NORMAL "\n", ac, pn); + printf(ANSI_HIGHLIGHT "Welcome to your new installation of " ANSI_NORMAL "\x1B[%sm%s" ANSI_HIGHLIGHT "!" ANSI_NORMAL "\n", ac, pn); else - printf("\nWelcome to your new installation of %s!\n", pn); + printf("Welcome to your new installation of %s!\n", pn); putchar('\n'); if (emoji_enabled()) { @@ -1241,6 +1244,8 @@ static int help(void) { " --force Overwrite existing files\n" " --delete-root-password Delete root password\n" " --welcome=no Disable the welcome text\n" + " --chrome=no Don't show color bar at top and bottom of\n" + " terminal\n" " --reset Remove existing files\n" "\nSee the %s for details.\n", program_invocation_short_name, @@ -1284,6 +1289,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_FORCE, ARG_DELETE_ROOT_PASSWORD, ARG_WELCOME, + ARG_CHROME, ARG_RESET, }; @@ -1321,6 +1327,7 @@ static int parse_argv(int argc, char *argv[]) { { "force", no_argument, NULL, ARG_FORCE }, { "delete-root-password", no_argument, NULL, ARG_DELETE_ROOT_PASSWORD }, { "welcome", required_argument, NULL, ARG_WELCOME }, + { "chrome", required_argument, NULL, ARG_CHROME }, { "reset", no_argument, NULL, ARG_RESET }, {} }; @@ -1530,6 +1537,13 @@ static int parse_argv(int argc, char *argv[]) { arg_welcome = r; break; + case ARG_CHROME: + r = parse_boolean_argument("--chrome=", optarg, &arg_chrome); + if (r < 0) + return r; + + break; + case ARG_RESET: arg_reset = true; break; @@ -1674,6 +1688,7 @@ static int run(int argc, char *argv[]) { } LOG_SET_PREFIX(arg_image ?: arg_root); + DEFER_VOID_CALL(chrome_hide); /* We check these conditions here instead of in parse_argv() so that we can take the root directory * into account. */ diff --git a/src/shared/prompt-util.c b/src/shared/prompt-util.c index 5c3fa98a922..927ef0770e9 100644 --- a/src/shared/prompt-util.c +++ b/src/shared/prompt-util.c @@ -213,7 +213,7 @@ int chrome_show( return 0; unsigned n = lines(); - if (n < 12) /* Do not bother with the chrom on tiny screens */ + if (n < 12) /* Do not bother with the chrome on tiny screens */ return 0; _cleanup_free_ char *b = NULL, *ansi_color_reverse = NULL; @@ -317,7 +317,7 @@ void chrome_hide(void) { printf("\x1B[%u;1H" ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE "\n" ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE "\n" - ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE ANSI_NORMAL, + ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE, n - 2); /* Reset scrolling area (DECSTBM) */