firstboot: show blue "chrome" bar at top

This commit is contained in:
Lennart Poettering
2025-09-24 15:46:30 +02:00
parent 8191bbd23c
commit 73ee723aa7
3 changed files with 32 additions and 7 deletions
+20 -5
View File
@@ -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. */
+2 -2
View File
@@ -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) */