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 | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 96abfda2f..a2f7baffa 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,
+ msg_len = grub_utf8_to_ucs4_alloc (msg_title,
&unicode_msg, &last_position);
- grub_free (msg_formatted);
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