From: "Jiří Wolker via Grub-devel" <grub-devel@gnu.org>
To: grub-devel@gnu.org
Cc: "Jiří Wolker" <projects@jwo.cz>
Subject: [PATCH v2 1/3] Customization of GRUB menu title
Date: Sun, 25 May 2025 21:55:50 +0200 [thread overview]
Message-ID: <87bjrexltg.fsf@jwo.cz> (raw)
In-Reply-To: <87plfuz2bb.fsf@gnat.mail-host-address-is-not-set>
Since these changes, the module ‘normal’ initializes environment variable
‘grub_menu_title’ with the previously hardcoded text. The variable is
automatically exported, so it applies also to submenus.
Scripts may change this variable to change the title of the menu.
---
grub-core/normal/main.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 96abfda2f..b341cebe0 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -203,19 +203,18 @@ grub_normal_init_page (struct grub_term_output *term,
{
grub_ssize_t msg_len;
int posx;
- char *msg_formatted;
+ const char *msg_title;
grub_uint32_t *unicode_msg;
grub_uint32_t *last_position;
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
- if (!msg_formatted)
+ msg_title = grub_env_get ("grub_menu_title");
+ if (! msg_title)
return;
- msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
- &unicode_msg, &last_position);
- grub_free (msg_formatted);
+ msg_len = grub_utf8_to_ucs4_alloc (msg_title,
+ &unicode_msg, &last_position);
if (msg_len < 0)
{
@@ -315,6 +314,16 @@ static grub_err_t
grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
+ if (grub_env_get ("grub_menu_title") == NULL)
+ {
+ /* Initialize the menu title with a GRUB version information. */
+ char *title;
+ title = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ grub_env_set ("grub_menu_title", title);
+ grub_free (title);
+ grub_env_export ("grub_menu_title");
+ }
+
if (argc == 0)
{
/* Guess the config filename. It is necessary to make CONFIG static,
--
2.45.3
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2025-05-27 12:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 11:54 [PATCH v2 0/3] Allow script-configurable GRUB menu title Jiří 'bindiff' Wolker via Grub-devel
2025-05-25 19:55 ` Jiří Wolker via Grub-devel [this message]
2025-05-26 16:15 ` [PATCH v2 2/3] Option to set title of submenus Jiří Wolker via Grub-devel
2025-05-27 13:14 ` Vladimir 'phcoder' Serbinenko
2025-05-27 13:18 ` Jiří 'bindiff' Wolker via Grub-devel
2025-05-26 16:21 ` [PATCH v2 3/3] Documentation for the --menutitle option Jiří ‘bindiff’ Wolker via Grub-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bjrexltg.fsf@jwo.cz \
--to=grub-devel@gnu.org \
--cc=projects@jwo.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.