Skip to content

Commit

Permalink
More advanced detection of existing oses
Browse files Browse the repository at this point in the history
  • Loading branch information
shadichy committed Dec 8, 2024
1 parent 938645c commit 7b867ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
56 changes: 37 additions & 19 deletions iso/boot/grub/functions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,43 @@ return 1
function efi_detect {
if is_efi ; then
submenu --class=find.efi --hotkey=f "Detect EFI bootloaders" {
efi_found=false

for efi in (*,*)/efi/*/*.efi (*,*)/efi/*/*/*.efi (*,*)/*.efi (*,*)/*/*.efi ; do
regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
if [ -e "${efi}" ]; then
efi_found=true

menuentry --class=efi "${efi}" "${efi_device}" {
regexp --set=1:efi_name '/([A-Za-z]+)(x64|ia32)?\.efi$' "${efi}"
tr -s efi_name_d -D "${efi_name}"
regexp --set=1:efi_base '/(\w+)/[A-Za-z]+(x64|ia32)?\.efi$' "${efi}"
tr -s os_class -D "${efi_base}"
os_name=""
if [ "${efi_name_d}" == "bootmgfw" -o "${efi_name_d}" == "bootmgr" ]; then
os_name=Windows
os_class=windows
elif [ "${efi_name_d}" == "opencore" ]; then
os_name=OpenCore
os_class=macosx
elif [ "${efi_name_d}" == "clover" ]; then
os_name=Clover
os_class=macosx
elif [ -n "${os_class}" -a "${os_class}" != "boot" -a "${os_class}" != "efi" ]; then
os_name=${efi_base}
else
os_class=efi
fi
if [ -z "${os_name}" ]; then
os_name=${efi}
else
os_name="(${efi_device}) ${os_name} ${efi_name}.efi"
if [ -z "${os_class}" ]; then
os_class=unknown
fi
fi
menuentry --class "${os_class}" --class unknown "${os_name}" "${efi_device}" {
root="${2}"
chainloader "${1}"
}
fi
done

if [ "${efi_found}" != true ]; then
menuentry --hotkey=q --class=find.none "No EFI files detected." {menu_reload}
else
menuentry --hotkey=q --class=cancel "Cancel" {menu_reload}
fi
menuentry --hotkey=q --class cancel "Cancel" {menu_reload}
}
fi
}
Expand All @@ -45,7 +63,7 @@ function memtest_detect {
}

function toggle_pcmode {
submenu --class="toggle_pcmode" "PC_MODE" {
submenu --class driver --class="toggle_pcmode" "PC_MODE" {
menuentry --class="enable_pcmode" "Enable PC_MODE" {
pcmode=PC_MODE=1
menu_reload
Expand All @@ -58,7 +76,7 @@ function toggle_pcmode {
}

function toggle_ffmpeg {
submenu --class="toggle_ffmpeg" "FFMPEG" {
submenu --class driver --class="toggle_ffmpeg" "FFMPEG" {
menuentry --class="enable_ffmpeg" "Enable FFMPEG" {
ffmpeg="FFMPEG_CODEC=1 FFMPEG_PREFER_C2=1"
menu_reload
Expand All @@ -71,7 +89,7 @@ function toggle_ffmpeg {
}

function toggle_setupwizard {
submenu --class="toggle_setupwizard" "Setup Wizard" {
submenu --class driver --class="toggle_setupwizard" "Setup Wizard" {
menuentry --class="enable_setupwizard" "Disable Setup Wizard" {
setupwizard=SETUPWIZARD=0
menu_reload
Expand All @@ -84,7 +102,7 @@ function toggle_setupwizard {
}

function toggle_hwaccel {
submenu --class="toggle_hwaccel" "Hardware Acceleration" {
submenu --class driver --class="toggle_hwaccel" "Hardware Acceleration" {
menuentry --class="enable_hwaccel" "Disable Hardware Acceleration" {
hwaccel="nomodeset HWACCEL=0"
menu_reload
Expand All @@ -97,18 +115,18 @@ function toggle_hwaccel {
}

function add_entry {
menuentry --class "$1-blissos" "$1 $TITLE" {
menuentry --class blissos --class "$1-blissos" "$1 $TITLE" {
linux "${KERNEL}" $KERNEL_ARGS $2 $pcmode $ffmpeg $hwacccel $setupwizard $iso
initrd "${INITRD}"
}
}

function power_options {
submenu --class power "Power options" {
submenu --class power --class shutdown "Power options" {
if is_efi; then
menuentry --class setup "UEFI firmware settings" { fwsetup }
menuentry --class efi "UEFI firmware settings" { fwsetup }
fi
menuentry --class reboot "Reboot" { reboot }
menuentry --class restart "Reboot" { reboot }
menuentry --class shutdown "Poweroff" { halt }
}
}
Expand Down
2 changes: 1 addition & 1 deletion iso/boot/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi
add_entry Try
add_entry Install "INSTALL=install.sfs"

submenu --class forward "Advanced options" {
submenu --class brunch-settings --class forward "Advanced options" {
toggle_ffmpeg
toggle_pcmode
toggle_hwaccel
Expand Down

0 comments on commit 7b867ee

Please sign in to comment.