Skip to content

Commit

Permalink
Rephrase the explanation
Browse files Browse the repository at this point in the history
because apparently i care so much about it
  • Loading branch information
Lxtharia committed May 24, 2024
1 parent 41e3960 commit ee0acca
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
| [Minecraft Main Menu](https://github.com/Lxtharia/minegrub-theme) | [Minecraft World Selection Menu](https://github.com/Lxtharia/minegrub-world-sel-theme) | *> Using both themes together <* |
| --- | --- | --- |

- **ADDITIONALLY!:** Check out this minecraft plymouth theme by nikp123 for a minecraft loading screen during boot: https://github.com/nikp123/minecraft-plymouth-theme

# The REAL minecraft experience when booting your system!

This is a guide on how you can have two grub menus after one another, each in a different theme!
Expand Down Expand Up @@ -64,50 +66,50 @@ Yea, its possible, and its fun
[Ventoy](https://www.ventoy.net/en/index.html) is using a modified version of grub, but has theme support.
If you want Ventoy to use both themes see [here.](./ventoy/README.md)
# Explanation
When grub starts, it by default reads the file `grub.cfg` usally located in `/boot/grub/grub.cfg` to set all the options (like timeout, default boot option, theme) and add all the boot options.
This file is usually generated by `grub-mkconfig` which uses variables set in `/etc/default/grub` and scripts in `/etc/grub.d/*` to create the full config file.
# Explanation (???)
oh boi here we go:
We have our cool theme to select our distro, but now we want a main menu "before it".
**NOW:** what do we want? (the results to be)
We want to be greeted with the minecraft looking main menu with options like "Singleplayer" "Multiplayer" "Minecraft Realms" (but with cool different nerd terms, see below) and if we select Singleplayer we want to see the world selection menu with all the boot options. If we press escape we return to the main menu.
When grub starts, it by default reads the file `grub.cfg` usually located in `/boot/grub/grub.cfg` to set all the options (like timeout, default boot option, theme) and add all the boot options.
This file is usually generated by `grub-mkconfig` which uses configuration options set in `/etc/default/grub` and scripts in `/etc/grub.d/*` to create the full config file.
**NOW:** what do we want? (in funcional terms)
We want grub to read a .cfg file that sets the theme to the main menu theme (`./mainmenu.cfg`) and that includes boot options like "Singlebooter" "Onlinebooter" or "UEFI Realms" (so cool).
And if we select "Singlebooter" we want to load "the real config file" that sets the world-selection theme and that includes all of your personal boot options.
**NOW:** what do we need?
- We need some code to auto-load another config file
- To get following code in `grub.cfg` we write it in a file (`05_twomenus`) and put it in `/etc/grub.d/` so it gets included when generating the grub.cfg
We want grub to read a second `.cfg` file that sets the theme to the main menu theme (`./mainmenu.cfg`) and that includes boot options like "Singlebooter" "Onlinebooter" or "UEFI Realms" (so cool).
And if we select "Singlebooter" we want to load "the real config file" with the world-selection theme and that includes all of your personal boot options.
- We need some code to autoload another config file
- To get the code that does that into `grub.cfg` we write it in a file (`05_twomenus`) and put it in `/etc/grub.d/`, so it gets included when generating the grub.cfg
- To automatically load another configfile we can just call `configfile $prefix/mainmenu.cfg` in grub.cfg
- `$prefix` contains the disk/partition absolute path to your `/boot/grub` folder
- We put this line in an if clause that will check if the enviromental variable `config_file=` is set
- if yes, we load that file (`configfile $prefix/$config_file`)
- the normally generated grub.cfg automatically loads variables from the file /boot/grub/grubenv, so all we have to do is set it there
- with `grub-editenv - set config_file=mainmenu.cfg`
- For some reason I thought it was a good idea to turn it off easily:
- We only load the main-menu if the environmental variable `config_file=` is set
- if yes, we load that file (with `configfile $prefix/$config_file`)
- `grub.cfg` normally loads variables automatically from the file `/boot/grub/grubenv`, so all we have to do is set it there
- with `grub-editenv - set config_file=mainmenu.cfg`
- now mainmenu.cfg gets loaded.
- the first boot item will load our grub.cfg again.
- the first boot item will load our `grub.cfg`-configfile again.
- BUT:
- to prevent grub.cfg to load the other config file again, we put that code into another if clause
- when we select an item, grub sets the variable `chosen`, so we can only load the config file if this variable has not been set yet
- and that's it!
So all we need is:
- A manual config file for the main menu
- A few extra lines of code in the grub.cfg file
- the enviromental variable `config_file`

TLDR:
- grub.cfg loads enviromental variables from /boot/grub/grubenv automatically
- we want grub.cfg to load our main theme .cfg automatically (by reading the env variable `config_file`)
- we now have our main menu and if we select "Singlebooter" it loads the grub.cfg again.

**TLDR:**
- `grub.cfg` tries to load a second config_file if the grub environmental variable `config_file` is set
- this config file shows us the main menu
- if we select "Singlebooter" it loads the grub.cfg again
- but now the "chosen" variable is set (because we have chosen an option)
- If this variable is set, we prevent the grub.cfg to load mainmenu.cfg and we see our normal boot options
- and if this variable is set, we prevent the grub.cfg to load mainmenu.cfg, and we see our normal boot options

# Notes
# Notes (!!!)
- the fun zone
- i write unnessesarily long READMEs

- I write unnesessarily long READMEs
- you don't have to READ IT, but you did read (until) this line, so: Hello :D
- if you generate or copy your grub.cfg to /boot/grub/custom.cfg your grub will be stuck in an infinite loop! (Luckily I learned that in a VM)
- This took more energy from me than it should've
- I'm happy how it turned out, can't wait for all the merge requests ha ha
- Fun-fact: if you generate or copy your grub.cfg to /boot/grub/custom.cfg your grub will be stuck in an infinite loop! (Luckily I learned that in a VM)
- I'm proud of this
- USE THIS ON YOUR OWN RISK, if your grub is broken i take no responsibilty, better have that live boot stick ready
- Also check out this minecraft plymouth theme by nikp123 for a minecraft loading screen during boot: https://github.com/nikp123/minecraft-plymouth-theme

0 comments on commit ee0acca

Please sign in to comment.