a1ive / grub2-filemanager

GRUB2-based file manager
https://a1ive.github.io/grub2-filemanager/
GNU General Public License v3.0
527 stars 106 forks source link

[Feature Request] Initial Boot Menu #128

Closed BiatuAutMiahn closed 4 years ago

BiatuAutMiahn commented 4 years ago

I was wondering if you could implement an initial boot menu, like (hd0,msdos1)/menu.cfg with the theme and the ability to switch over to the File manager with the F2 Key? Thank you

a1ive commented 4 years ago

You can create file "/boot/grubfm/config" on your disk and init.sh will load it before filemanager starts. https://github.com/a1ive/grub2-filemanager/blob/44f47df572279dce6102b4338bec711361412e93/boot/grubfm/init.sh#L76-L81

steve6375 commented 4 years ago

Example config file (actually startup_menu.txt file used by Easy2Boot)

#USER CONFIG FILE
#Displays up to ten user menu entries (uncomment lines and change paths as required).
#Menu items are only listed if the file exists.

set timeout=5
set default=0

#Uncomment a line below if required
#0 if you want agFM to show all files in each folder on startup (1=default)
#grubfm_set --hide 0
#grubfm_set --hide 1

#0 to always show secondary menu, 1=run .cfg,.VHD and some other files immediately (no secondary menu) 1=default
#grubfm_set --boot 0
#grubfm_set --boot 1

#unset to not sort files by name, 1 to sort alphabetically (default)
#unset grubfm_disable_qsort
#export grubfm_disable_qsort=1

#SET STYLE (change section below if required)
#0=standard agFM theme
#1=e2b 'slack' theme         (rename folder \boot\grubfm\themes\sample_slack to slack) NO SPACES
#2=User wallpaper, no theme  (change section below)
set mymenu=2
#specify theme folder name, e.g. slack (no spaces)
set mytheme="seven"

#set language: en_US, ru_RU, fr_FR, tr_TR, ko_KR, ja_JP, zh_CN, de_DE, he_IL, vi_VN, es_EM, zh_TW
#export lang=de_DE

#DIAG=1 to enable Partition Table info menu entry (0=disable diagnostic entry)
set DIAG=1

#MENU ENTRIES
#File names and paths may be CASE-SENSITIVE!
#The grubfm*_type variable must either be "wininst", "e2biso" or ""
#type: use 'e2biso' to boot immediately using partnew 
#  or 'wininst' for Windows Install ISO 
#  or do not set a type to allow user choice from menu.
#  for .cfg and .imgptn files, do not set a type - they will auto-run (if grubfm_set --boot=1 is used)

set grubfm0="(hd0,msdos1)/_ISO/WINDOWS/WIN10/Windows10-64-Nov2018.imgPTN23"
set grubfm0_title="Windows 10 64-bit English (Secure Boot)"
set grubfm0_type=""

set grubfm0=(hd0,msdos1)/_ISO/WINDOWS/WIN10/Windows10_1909_x64_English_MS.iso
set grubfm0_title="Windows 10 64-bit English"
#set grubfm0_title="(hd0,msdos1)/_ISO/MAINMENU/.."
set grubfm0_type="wininst"

set grubfm1="(hd0,msdos1)/_ISO/UTILITIES_MEMTEST/Passmark Memtest86 (MBR+UEFI).imgPTN23"
set grubfm1_title="Passmark Memtest86 (UEFI)"
set grubfm1_type=""

set grubfm2="(hd0,msdos1)/_ISO/WINDOWS/WIN10/Windows10x64UK.iso"
set grubfm2_title="Windows 10 x64 UK (ISO)"
set grubfm2_type="wininst"

set grubfm3="(hd0,msdos1)/_ISO/LINUX/ubuntu-18.04.3-desktop-amd64.iso"
set grubfm3_title="Ubuntu 18.04.3 64-bit (ISO)"
set grubfm3_type="e2biso"

set grubfm4="(${user})/RESTORE_E2B.cfg"
set grubfm4_title="Restore E2B partitions"
set grubfm4_type=""

set grubfm5="(hd0,msdos1)/_ISO/WINPE/Gandalf's Win10PEx64Redstone3-07-10-2018.ISOPE"
set grubfm5_title="Gandalf's Redstone 3 WinPE (2018-10-07)"
set grubfm5_type=""

set grubfm6="(hd0,msdos1)/_ISO/WINDOWS/WIN10/18363.657.Vanadium-X64-DE-XXL-SUPER-MULTI.ISO"
set grubfm6_title="18363.657.Vanadium-X64-DE-XXL-SUPER-MULTI.ISO"
set grubfm6_type="wininst"

#set grubfm7="changeme"
#set grubfm7_title="changeme"
#set grubfm7_type=""

#set grubfm8="changeme"
#set grubfm8_title="changeme"
#set grubfm8_type=""

#set grubfm9="changeme"
#set grubfm9_title="changeme"
#set grubfm9_type=""

##### USER seven GRUB2 THEME ######
if [ "${mymenu}" = "1" ] ; then
#Rename \boot\grubfm\themes\sample_slack folder to slack then edit background.png to add your own wallpaper
#uncomment 'menu_pixmap_style' in each .txt file to add a grey box behind the menu text
    export theme_std="(${user})/boot/grubfm/themes/${mytheme}/theme.txt";
    export theme_fm="(${user})/boot/grubfm/themes/${mytheme}/fm.txt";
    export theme_open="(${user})/boot/grubfm/themes/${mytheme}/open.txt";
    export theme_info="(${user})/boot/grubfm/themes/${mytheme}/info.txt";
    export theme_help="(${user})/boot/grubfm/themes/${mytheme}/help.txt";
    export theme=$theme_std
    #themes must not contain spaces
    if ! [ -f "$theme" ] ; then echo "ERROR: Can't find $theme" ; read ; fi
fi
####################################

######## MYMENU=2 - USER MENU CONFIG ##########
if [ "${mymenu}" = "2" ] ; then
    #Remove standard agFM theme - comment out if you want standard agFM theme for agFM
    unset theme_std; unset theme_fm; unset theme_open; unset theme_info; unset theme_help;
    #Don't use a theme for this menu
    unset theme
    #set resolution (1024x768 recommended)
    set gfxmode=1024x768
    terminal_output gfxterm
    set gfxpayload=1024x768
    #Menu colours - format: text/background  (black background=transparent)
    #Choice: black,blue,brown,cyan,dark-gray,green,light-cyan,light-blue,light-green,light-gray,light-magenta,light-red,magenta,red,white,yellow
    set menu_color_highlight=yellow/black
    set menu_color_normal=light-green/black
    set color_normal=light-gray/black
    #add either your background image or a fill colour - use stretch or normal - .png, .tga, .jpg, or .jpeg
    background_image -m stretch (${user})/boot/grubfm/seven.jpg
    #valid fill_colors: black,blue,brown,cyan,green,gray,magenta,red,white,yellow
    ###background_color magenta
fi
###########################################

# === DO NOT CHANGE ANY LINES BELOW HERE ===

#grubfm must not be menu entry 1 or above (either 0 or remove this entry)
menuentry "a1ive grub2 File Manager" --class=dir {
    if [ -d "(hd0,msdos1)/_ISO/MAINMENU" ] ; then 
        grubfm "(hd0,msdos1)/_ISO/MAINMENU/"
    else
        grubfm
    fi
}

if [ -f "${grubfm0}" ] ; then 
menuentry "${grubfm0_title}" --class=exe {
set grubfm_file="${grubfm0}"
if [ "${grubfm0_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm0_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm0}"
}
fi

if [ -f "${grubfm1}" ] ; then 
menuentry "${grubfm1_title}" --class=exe {
set grubfm_file="${grubfm1}"
if [ "${grubfm1_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm1_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm1}"
}
fi

if [ -f "${grubfm2}" ] ; then 
menuentry "${grubfm2_title}" --class=exe {
set grubfm_file="${grubfm2}"
if [ "${grubfm2_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm2_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm2}"
}
fi

if [ -f "${grubfm3}" ] ; then 
menuentry "${grubfm3_title}" --class=exe {
set grubfm_file="${grubfm3}"
if [ "${grubfm3_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm3_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm3}"
}
fi

if [ -f "${grubfm4}" ] ; then 
menuentry "${grubfm4_title}" --class=exe {
set grubfm_file="${grubfm4}"
if [ "${grubfm4_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm4_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm4}"
}
fi

if [ -f "${grubfm5}" ] ; then 
menuentry "${grubfm5_title}" --class=exe {
set grubfm_file="${grubfm5}"
if [ "${grubfm5_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm5_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm5}"
}
fi

if [ -f "${grubfm6}" ] ; then 
menuentry "${grubfm6_title}" --class=exe {
set grubfm_file="${grubfm6}"
if [ "${grubfm6_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm6_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm6}"
}
fi

if [ -f "${grubfm7}" ] ; then 
menuentry "${grubfm7_title}" --class=exe {
set grubfm_file="${grubfm7}"
if [ "${grubfm7_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm7_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm7}"
}
fi

if [ -f "${grubfm8}" ] ; then 
menuentry "${grubfm8_title}" --class=exe {
set grubfm_file="${grubfm8}"
if [ "${grubfm8_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm8_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm8}"
}
fi

if [ -f "${grubfm9}" ] ; then 
menuentry "${grubfm9_title}" --class=exe {
set grubfm_file="${grubfm9}"
if [ "${grubfm9_type}" = "wininst" ] ; then configfile (${user})/boot/grubfm/rules/iso/win.sh ; fi
if [ "${grubfm9_type}" = "e2biso" ]  ; then configfile (${user})/boot/grubfm/rules/iso/e2b.sh ; fi
grubfm_open "${grubfm9}"
}
fi

if [ "$DIAG" = "1" ] ; then
menuentry "Display USB partition tables" --class=info {
    echo "Partition type........||  (07=NTFS, 0B\0C\0E=FAT32, 0F=Extended\Logical"
    echo "                      ||"
    echo "hd0 MBR (LBA0)        vv           [  START  ] [ LENGTH  ]"
    hexdump -s 0x1be -n 0x40 (hd0)0+1
    echo
    echo "hd0 MBR Copy (LBA30)"
    hexdump -s 0x1be -n 0x40 (hd0)30+1
    echo
    echo "hd0 MBR Backup (LBA60)"
    hexdump -s 0x1be -n 0x40 (hd0)60+1
    echo
    ls
    echo -n Press a key...
    read
}
fi
BiatuAutMiahn commented 4 years ago

I saw that snippet in the source, but doesn't seem to work. (cd)/boot/grubfm/config

menuentry "WinPE" --unrestricted --class Windows {
  loopback wim (memdisk)/boot/grubfm/wimboot.gz
  linux16 (wim)/wimboot
  initrd16 \
  newc:bootmgr:(wim)/bootmgr \
  newc:bootmgr.exe:(wim)/bootmgr.exe \
  newc:bcd:(wim)/bcd \
  newc:boot.sdi:(wim)/boot.sdi \
  newc:boot.wim:/boot.wim
}

image

BiatuAutMiahn commented 4 years ago

I know it is reading the file cause adding terminal_output console; does switch to console mode at boot.

steve6375 commented 4 years ago

What exactly is the problem??? 'it doesn't work' is not exactly much to go on is it!

Is the path correct? newc:boot.wim:/boot.wim

???

BiatuAutMiahn commented 4 years ago

Instead of showing available drives on start, I'm looking to show a custom menu maintaining the theme, and still have the option to goto the file manager

steve6375 commented 4 years ago

That is exactly what the example does!

BiatuAutMiahn commented 4 years ago

Using what you posted verbatim results in this: image Honestly not trying to be a pain.

steve6375 commented 4 years ago
#SET STYLE (change section below if required)
#0=standard agFM theme
#1=e2b 'slack' theme         (rename folder \boot\grubfm\themes\sample_slack to slack) NO SPACES
#2=User wallpaper, no theme  (change section below)
set mymenu=2

just set mymenu to 0

steve6375 commented 4 years ago

1 = You can have your own modified slack scheme by copying the slack theme folder (get it from inside the grubfm.iso file and copy to \boot\grubfm\themes folder on your drive). or keep original theme (0) or use wallpaper+text menu (2)

BiatuAutMiahn commented 4 years ago

After setting mymenu=0 image

steve6375 commented 4 years ago

Well you obviously have to add you own menu entries!!! It isn't magic!

set grubfm0="(hd0,msdos1)/_ISO/WINDOWS/WIN10/Windows10-64-Nov2018.imgPTN23" set grubfm0_title="Windows 10 64-bit English (Secure Boot)" set grubfm0_type=""

and always use grubfmx_type="" for you as you do not have user .sh files.

BiatuAutMiahn commented 4 years ago

No offense, but my request isn't unreasonable and I don't appreciate your 'yelling' at me. I am being professional and will remain that way.

I believe your misunderstanding my intent here. I want nothing to do with E2B as it's layout is rather complicated imo.

with grubfm, if I load a custom menu.cfg I see this: image

My goal was to be able to do this at boot using standard grub2 config files.

I do apologize if I'm not understanding.

Thank you

steve6375 commented 4 years ago

Sorry, I don't understand. Isn't that menu showing on boot? What do you mean by 'standard grub2 config files'? If you want standard grub2 menu entries, then just add them into the config? What are you expecting to see?

BiatuAutMiahn commented 4 years ago

one moment, I'll post a screenshot

BiatuAutMiahn commented 4 years ago

It seems that I can't get the theme to work, but I fork'd your repo and implemented what im referring to: https://github.com/BiatuAutMiahn/grub2-filemanager

a1ive commented 4 years ago

(hd0,1)/boot/grubfm/config:

configfile (${user})/boot/grubfm/menu.cfg;

(hd0,1)/boot/grubfm/menu.cfg:

export theme="${theme_fm}";

menuentry "windows.iso" {
  grubfm_open "(hd0,1)/grubfm.iso";
}

menuentry "123456" {
  echo 123456;
}

hiddenentry "[F1] HELP" --hotkey f1 {
  configfile ${prefix}/help.sh;
}

hiddenentry "[F2] FILE MANAGER" --hotkey f2 {
    grubfm;
}

hiddenentry "[F3] OS DETECT" --hotkey f3 {
  configfile ${prefix}/osdetect.sh;
}

hiddenentry "[F4] SETTINGS" --hotkey f4 {
  configfile ${prefix}/settings.sh;
}

hiddenentry "[F5] PXE BOOT MENU" --hotkey f5 {
  configfile ${prefix}/netboot.sh;
}

hiddenentry "[F6] POWER OFF" --hotkey f6 {
  configfile ${prefix}/power.sh;
}
BiatuAutMiahn commented 4 years ago

This is the implementation that I was looking for. :) Changes:

image