Monday 4 May 2020

Add your own Help menu to agFM

If you have made your agFM MBR+UEFI-bootable USB stick, you might want to add some instructions for your users - or to act as a reminder for yourself on how to use the USB stick in case you forget in a few months time.

You could add a 'Help' menu entry to your Start-up menu and it could display help in the form of a jpg/bmp/png. For instance, you could write the help information in Word or PowerPoint, add your Logo or other graphics and diagrams, and then use a screen capture to save it as a 1024x768x24 colour .jpg file. Then you could simply display the jpg.

Another option would be to display text - perhaps in different colours too.

The following is an example help.cfg file which is saved in UTF-8 format (using Notepad) to preserve non-English glyphs. Note that if you use the text mode for your menu system (mymenu=3) then you should only use English ASCII characters, the background colours are restricted and graphics files (jpg/png/bmp) cannot be displayed.


#in console mode background colours are restricted to black,blue,brown,cyan,light-gray,green,magenta,red
set yellow="set color_normal=yellow/black"
set red="set color_normal=red/black"
set blue="set color_normal=light-blue/light-gray"
set white="set color_normal=light-gray/black"
set hlite="set color_normal=red/white"

menuentry "Help" --class=info {
echo -n "ãngstrom Ètude Ánti ";${yellow};echo -n "This is yellow";${red};echo -n " This is red ";${blue};echo -n "This is blue"
echo -e /n This is an example of how to write help text
echo -n "You can use colours like ";${red};echo -n "red";${white}; echo -n " or " ;$yellow; echo -n "yellow or " ;$blue; echo -n "blue"
echo ãngstrom Ètude Ánti
echo Press a key to continue

menuentry "Help " --class=png {
set bmp_path="(hd0,1)/_ISO/jolene 800.bmp";
lua ${prefix}/view.lua;

menuentry "Back  [F2] FILE MANAGER  [F3] OS  [F4] SETTINGS  [F6] POWER OFF" --class=go-previous {
grubfm "${grubfm_current_path}"

hiddenentry "[F2] FILE MANAGER" --hotkey f2 {

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

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

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

hiddenentry "[F6] POWER OFF" --hotkey f6 {
  configfile ${prefix}/;

The second 'help' item will display a jpg/bmp/png file.
The first 'help' displays text.

Note: agFM v1.50 and later include an enhanced 'echo' command.

Note that if you are using text mode (mymenu=3) then the background colour choice is limited to only eight colours.

Also, you should not assume that the current default text colour is light-gray/black, so always preserve the current text colour so that you can restore it after displaying you message, otherwise the colour of the text in some portions of the menu system may also be changed!

menuentry "Help" --class=info {

echo TEST grub2 coloured text
#syntax: \e0xbf where b=background and f=foreground text colour
#colours 0-f are black,blue,green,cyan,red,magenta,brown,light-gray,dark-gray,ligt-blue,light-green,light-cyan,light-red,light-magenta,yellow,white
#BUT in console text mode, background colours are 0-7 only.

#get current console colour as $n
set n="set color_normal=$color_normal"
echo -e -n "\e0x04This is red ";$n;echo -e -n "This is previous colour ";echo -e "\e0x71This is blue on grey"
#make sure we return to current console colour
unset n
echo -e -n "\nPress a key to continue..."

Note that you must specify -e and the text must be inside double-quotes. echo -n will prevent a new line from being thrown after the message is printed and if also using -e then you can use escape sequences such as \n (new line) or \t (tab) or \r (carriage return) too.

No comments:

Post a Comment