# Scutarius arm64 boot-menu header (netboot tree and mini.iso). The x86 one
# is upstream's boot/x86/grub/grub-efi.cfg patched (0004..0006) to the same
# look: the installer theme (build/boot/scutarius-theme.txt, copied as
# theme.txt next to splash.jpg and font.pf2 by config/arm.cfg, patch 0010),
# which draws the shield-wall background from build/boot/scutarius-splash.jpg
# and puts the menu BELOW its artwork, where GRUB's default menu box used to
# cover it. Only on a graphical terminal: gfxmenu draws nothing anywhere
# else. Without the theme, the background with the theme's colours; plain
# colours if the image cannot be shown either.
if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
   font=$prefix/font.pf2
fi
if loadfont $font ; then
  set gfxmode=1024x768,800x600,auto
  set gfxpayload=keep
  insmod efi_gop
  insmod gfxterm
  insmod jpeg
  terminal_output gfxterm
  set scutarius_gfx=y
fi
# (GRUB script has no && -- hence the nested ifs.)
# The theme's presence is tested by LOADING splash.jpg, not with
# `[ -f $prefix/theme.txt ]`: GRUB's network filesystem lists no directory
# entries (net.c grub_net_fs_dir reports nothing), so -f is false for every
# file on a PXE boot and the theme never loaded there. GRUB fell back to its
# plain framed menu with the picture stretched behind, and that frame and the
# entry editor ran straight across the artwork. splash.jpg and theme.txt are
# copied by the same build
# step, so a loadable image means the theme is there too -- on disk and over
# the network alike. The image is dropped again: gfxmenu draws its own.
if [ x$scutarius_gfx = xy ]; then
  if background_image $prefix/splash.jpg; then
    background_image
    if insmod gfxmenu; then
      set scutarius_theme=y
    fi
  fi
fi
if [ x$scutarius_theme = xy ]; then
  set theme=$prefix/theme.txt
  export theme
elif background_image -m stretch $prefix/splash.jpg; then
  set color_normal=light-gray/black
  set color_highlight=white/black
else
  set menu_color_normal=white/black
  set menu_color_highlight=black/light-gray
fi
# The menu on the board's serial console as well as the display. EDK2 exposes
# the UART as GRUB's efi0 (terminal "serial_efi0"), so GRUB never programs
# the UART itself. But the
# speed must still be NAMED: `serial efi0` without --speed reprograms the port
# to GRUB's default 9600, and no single value is right for every machine -- a
# universal 1500000 would be wrong for any board running another rate. So it is chosen per board
# from SMBIOS type 1's product name (offset 5, the same string Linux shows as
# /sys/class/dmi/id/product_name), and an unknown board gets NO serial mirror,
# exactly as before. Only boards with EVIDENCE belong in this table:
#   ROCK 5 Model B  1500000  Radxa ROCK 5B: efi0 present in GRUB (seen on
#                            HDMI); 1500000 is the device tree's stdout-path
#                            (serial2:1500000n8) and the rate EDK2 and the
#                            kernel use. Readable output NOT yet seen: no cable
#                            was attached. Confirm before trusting it.
# NOT the GB10s, deliberately: their 921600 exists only in configuration (an
# /etc/grub.d snippet and console= arguments), and no serial console has ever
# been seen working on one -- not even which physical port carries it. Add a
# row when a console has been watched, not before.
# --append keeps gfxterm and the theme (verified on the ROCK 5B's HDMI, with
# keyboard input in every phase); same idiom as the installed GB10 system's
# /etc/grub.d/05_scutarius_gb10_serial.
set scutarius_serial_speed=
if insmod smbios; then
  smbios --type 1 --get-string 5 --set scutarius_product
  if [ "x$scutarius_product" = "xROCK 5 Model B" ]; then
    set scutarius_serial_speed=1500000
  fi
fi
if [ -n "$scutarius_serial_speed" ]; then
  insmod serial
  if serial efi0 --speed=$scutarius_serial_speed --word=8 --parity=no --stop=1; then
    terminal_input --append serial_efi0
    terminal_output --append serial_efi0
  fi
fi
# 30 s so the menu can be caught over a KVM; the default is "Install" again
# (scutarius5/6 defaulted to the expert entry; reverted on the owner's ruling
# 2026-09-06). "... Expert install" stays under Advanced options (menu ids
# from our grub-gencfg patch: advanced>expert).
set timeout=30
set default='install'

insmod gzio
menuentry --id=install 'Install' {
    set background_color=black
    echo 'Loading the installer kernel ...'
    linux    /debian-installer/arm64/linux --- quiet
    echo 'Loading the initial ramdisk ...'
    initrd   /debian-installer/arm64/initrd.gz
    terminal_output console
}
submenu --hotkey=a --id=advanced 'Advanced options ...' {
    set color_normal=light-gray/black
    set color_highlight=white/black
    set gfxpayload=keep
    menuentry --id=expert '... Expert install' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux priority=low ---
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    menuentry '... Rescue mode' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux rescue/enable=true --- quiet
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    menuentry '... Automated install' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux auto=true priority=critical --- quiet
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    menuentry --hotkey=x '... Expert install with speech synthesis' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux priority=low speakup.synth=soft ---
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    menuentry --hotkey=r '... Rescue mode with speech synthesis' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux rescue/enable=true speakup.synth=soft --- quiet
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    menuentry --hotkey=a '... Automated install with speech synthesis' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux auto=true priority=critical speakup.synth=soft --- quiet
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    submenu '... Desktop environment menu ...' {
        set color_normal=light-gray/black
        set color_highlight=white/black
        set gfxpayload=keep
        submenu '... GNOME desktop boot menu ...' {
            set color_normal=light-gray/black
            set color_highlight=white/black
            set gfxpayload=keep
            menuentry '... Install' {
                set background_color=black
                echo 'Loading the installer kernel ...'
                linux    /debian-installer/arm64/linux desktop=gnome --- quiet
                echo 'Loading the initial ramdisk ...'
                initrd   /debian-installer/arm64/initrd.gz
                terminal_output console
            }
            submenu '... GNOME advanced options ...' {
                set color_normal=light-gray/black
                set color_highlight=white/black
                set gfxpayload=keep
                menuentry '... Expert install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=gnome priority=low ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry '... Automated install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=gnome auto=true priority=critical --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=x '... Expert install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=gnome priority=low speakup.synth=soft ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=a '... Automated install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=gnome auto=true priority=critical speakup.synth=soft --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
            }
        }
        submenu '... KDE Plasma desktop boot menu ...' {
            set color_normal=light-gray/black
            set color_highlight=white/black
            set gfxpayload=keep
            menuentry '... Install' {
                set background_color=black
                echo 'Loading the installer kernel ...'
                linux    /debian-installer/arm64/linux desktop=kde --- quiet
                echo 'Loading the initial ramdisk ...'
                initrd   /debian-installer/arm64/initrd.gz
                terminal_output console
            }
            submenu '... KDE Plasma advanced options ...' {
                set color_normal=light-gray/black
                set color_highlight=white/black
                set gfxpayload=keep
                menuentry '... Expert install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=kde priority=low ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry '... Automated install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=kde auto=true priority=critical --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=x '... Expert install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=kde priority=low speakup.synth=soft ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=a '... Automated install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=kde auto=true priority=critical speakup.synth=soft --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
            }
        }
        submenu '... LXDE desktop boot menu ...' {
            set color_normal=light-gray/black
            set color_highlight=white/black
            set gfxpayload=keep
            menuentry '... Install' {
                set background_color=black
                echo 'Loading the installer kernel ...'
                linux    /debian-installer/arm64/linux desktop=lxde --- quiet
                echo 'Loading the initial ramdisk ...'
                initrd   /debian-installer/arm64/initrd.gz
                terminal_output console
            }
            submenu '... LXDE advanced options ...' {
                set color_normal=light-gray/black
                set color_highlight=white/black
                set gfxpayload=keep
                menuentry '... Expert install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=lxde priority=low ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry '... Automated install' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=lxde auto=true priority=critical --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=x '... Expert install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=lxde priority=low speakup.synth=soft ---
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
                menuentry --hotkey=a '... Automated install with speech synthesis' {
                    set background_color=black
                    echo 'Loading the installer kernel ...'
                    linux    /debian-installer/arm64/linux desktop=lxde auto=true priority=critical speakup.synth=soft --- quiet
                    echo 'Loading the initial ramdisk ...'
                    initrd   /debian-installer/arm64/initrd.gz
                    terminal_output console
                }
            }
        }
    }
}
submenu --hotkey=d 'Accessible dark contrast installer menu ...' {
    set menu_color_normal=white/black
    set menu_color_highlight=yellow/black
    set color_normal=white/black
    set color_highlight=yellow/black
    background_image
    set gfxpayload=keep
    menuentry '... Install' {
        set background_color=black
        echo 'Loading the installer kernel ...'
        linux    /debian-installer/arm64/linux theme=dark --- quiet
        echo 'Loading the initial ramdisk ...'
        initrd   /debian-installer/arm64/initrd.gz
        terminal_output console
    }
    submenu --hotkey=a '... Advanced options ...' {
        set menu_color_normal=white/black
        set menu_color_highlight=yellow/black
        set color_normal=white/black
        set color_highlight=yellow/black
        background_image
        set gfxpayload=keep
        menuentry '... Expert install' {
            set background_color=black
            echo 'Loading the installer kernel ...'
            linux    /debian-installer/arm64/linux priority=low theme=dark ---
            echo 'Loading the initial ramdisk ...'
            initrd   /debian-installer/arm64/initrd.gz
            terminal_output console
        }
        menuentry '... Rescue mode' {
            set background_color=black
            echo 'Loading the installer kernel ...'
            linux    /debian-installer/arm64/linux rescue/enable=true theme=dark --- quiet
            echo 'Loading the initial ramdisk ...'
            initrd   /debian-installer/arm64/initrd.gz
            terminal_output console
        }
        menuentry '... Automated install' {
            set background_color=black
            echo 'Loading the installer kernel ...'
            linux    /debian-installer/arm64/linux auto=true priority=critical theme=dark --- quiet
            echo 'Loading the initial ramdisk ...'
            initrd   /debian-installer/arm64/initrd.gz
            terminal_output console
        }
    }
}
