int g_ventoy_tip_label_enable = 0;
const char * g_ventoy_tip_msg1 = NULL;
const char * g_ventoy_tip_msg2 = NULL;
+char g_ventoy_theme_path[256] = {0};
static const char *g_ventoy_cur_img_path = NULL;
static void menu_set_chosen_tip(grub_menu_t menu, int entry)
{
menu_tip *tip;
grub_menu_entry_t e = grub_menu_get_entry (menu, entry);
+ if (g_ventoy_theme_path[0])
+ {
+ grub_env_set("theme", g_ventoy_theme_path);
+ }
+
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
{
+ g_ventoy_theme_path[0] = 0;
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
if (img)
{
}
else if (e && e->id && grub_strncmp(e->id, "DIR_", 4) == 0)
{
+ g_ventoy_theme_path[0] = 0;
for (i = 0; i < e->argc; i++)
{
if (e->args[i] && grub_strncmp(e->args[i], "_VTIP_", 6) == 0)
{ "vt_sel_wimboot", ventoy_cmd_sel_wimboot, 0, NULL, "", "", NULL },
{ "vt_set_wim_load_prompt", ventoy_cmd_set_wim_prompt, 0, NULL, "", "", NULL },
{ "vt_set_theme", ventoy_cmd_set_theme, 0, NULL, "", "", NULL },
+ { "vt_set_theme_path", ventoy_cmd_set_theme_path, 0, NULL, "", "", NULL },
+ { "vt_select_theme_cfg", ventoy_cmd_select_theme_cfg, 0, NULL, "", "", NULL },
{ "vt_get_efi_vdisk_offset", ventoy_cmd_get_efivdisk_offset, 0, NULL, "", "", NULL },
{ "vt_search_replace_initrd", ventoy_cmd_search_replace_initrd, 0, NULL, "", "", NULL },
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
void ventoy_plugin_dump_persistence(void);
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
+grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args);
+grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
static image_list *g_image_list_head = NULL;
static conf_replace *g_conf_replace_head = NULL;
+static int g_theme_id = 0;
static int g_theme_num = 0;
static theme_list *g_theme_head = NULL;
static int g_theme_random = vtoy_theme_random_boot_second;
static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
{
const char *value;
+ char val[64];
char filepath[256];
VTOY_JSON *node = NULL;
theme_list *tail = NULL;
}
}
}
+
+ grub_snprintf(val, sizeof(val), "%d", g_theme_num);
+ grub_env_set("VTOY_THEME_COUNT", val);
+ grub_env_export("VTOY_THEME_COUNT");
+ if (g_theme_num > 0)
+ {
+ vtoy_json_get_int(json->pstChild, "default_file", &g_theme_id);
+ if (g_theme_id > g_theme_num || g_theme_id < 0)
+ {
+ g_theme_id = 0;
+ }
+ }
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
if (value)
return 0;
}
+grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ int pos = 0;
+ int bufsize = 0;
+ char *name = NULL;
+ char *buf = NULL;
+ theme_list *node = NULL;
+
+ (void)argc;
+ (void)args;
+ (void)ctxt;
+
+ if (g_theme_single_file[0])
+ {
+ return 0;
+ }
+
+ if (g_theme_num < 2)
+ {
+ return 0;
+ }
+
+ bufsize = (g_theme_num + 1) * 1024;
+ buf = grub_malloc(bufsize);
+ if (!buf)
+ {
+ return 0;
+ }
+
+ for (node = g_theme_head; node; node = node->next)
+ {
+ name = grub_strstr(node->theme.path, ")/");
+ if (name)
+ {
+ name++;
+ }
+ else
+ {
+ name = node->theme.path;
+ }
+
+ pos += grub_snprintf(buf + pos, bufsize - pos,
+ "menuentry \"%s\" --class=debug_theme_item --class=debug_theme_select --class=F5tool {\n"
+ "vt_set_theme_path \"%s\"\n"
+ "}\n",
+ name, node->theme.path);
+ }
+
+ pos += grub_snprintf(buf + pos, bufsize - pos,
+ "menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {\n"
+ "echo 'Return ...'\n"
+ "}\n");
+
+ grub_script_execute_sourcecode(buf);
+ grub_free(buf);
+
+ return 0;
+}
+
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i = 0;
{
goto end;
}
+
+ if (g_theme_id > 0 && g_theme_id <= g_theme_num)
+ {
+ for (i = 0; i < (grub_uint32_t)(g_theme_id - 1) && node; i++)
+ {
+ node = node->next;
+ }
+
+ grub_env_set("theme", node->theme.path);
+ goto end;
+ }
grub_memset(&datetime, 0, sizeof(datetime));
grub_get_datetime(&datetime);
grub_env_set("theme", node->theme.path);
end:
+
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
+extern char g_ventoy_theme_path[256];
+grub_err_t ventoy_cmd_set_theme_path(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ (void)argc;
+ (void)ctxt;
+
+ if (argc == 0)
+ {
+ g_ventoy_theme_path[0] = 0;
+ }
+ else
+ {
+ grub_snprintf(g_ventoy_theme_path, sizeof(g_ventoy_theme_path), "%s", args[0]);
+ }
+
+ VENTOY_CMD_RETURN(GRUB_ERR_NONE);
+}
}
}
+if [ $VTOY_THEME_COUNT -gt 1 ]; then
+ submenu "Theme Select" --class=debug_theme_select --class=F5tool {
+ vt_select_theme_cfg
+ }
+fi
+
if [ "$grub_platform" != "pc" ]; then
submenu 'Ventoy UEFI Utilities' --class=debug_util --class=F5tool {
menuentry 'Show EFI Drivers' --class=debug_util_efidrv --class=debug_util --class=F5tool {