{"id":24462059,"url":"https://github.com/ndoy3m4n/galsen-grub","last_synced_at":"2025-04-13T05:53:06.605Z","repository":{"id":57117914,"uuid":"526929944","full_name":"NDOY3M4N/galsen-grub","owner":"NDOY3M4N","description":"Grub Theme Made In Senegal","archived":false,"fork":false,"pushed_at":"2022-08-21T12:06:20.000Z","size":8077,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T05:53:00.054Z","etag":null,"topics":["grub2-theme","linux"],"latest_commit_sha":null,"homepage":"https://ndoy3m4n.github.io/galsen-grub/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NDOY3M4N.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-20T13:09:43.000Z","updated_at":"2025-03-03T21:55:48.000Z","dependencies_parsed_at":"2022-08-23T05:41:08.995Z","dependency_job_id":null,"html_url":"https://github.com/NDOY3M4N/galsen-grub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDOY3M4N%2Fgalsen-grub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDOY3M4N%2Fgalsen-grub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDOY3M4N%2Fgalsen-grub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDOY3M4N%2Fgalsen-grub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NDOY3M4N","download_url":"https://codeload.github.com/NDOY3M4N/galsen-grub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670503,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grub2-theme","linux"],"created_at":"2025-01-21T04:30:47.655Z","updated_at":"2025-04-13T05:53:06.577Z","avatar_url":"https://github.com/NDOY3M4N.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pimp my GRUB\n\n\u003cimg src=\"https://user-images.githubusercontent.com/46305144/185753718-b48f0e74-f289-414d-892b-bb7071f9fcab.png\" /\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/GalsenDev221/made.in.senegal/blob/master/assets/badge.svg\" /\u003e\n\u003c/p\u003e\n\nIn this tutorial, I'll show you how we can change the default appearance of the GRUB.\n\nWanna see the slides? Check this [link](https://ndoy3m4n.github.io/galsen-grub/).\n\n\n## 🤔 What is GRUB?\n\nGNU GRUB is a very powerful bootloader, which can load a wide variety of free operating systems, as well as proprietary operating systems. GRUB stands for **GRand Unified Bootloader** and is designed to address the complexity of booting a personal computer.\nCurrently we are on version 2.0.6, a complete upgrade of the previous version. In this version, we have some new features like a graphical menu.\n\n\n## 💄 Theme file definition\n\nGRUB's graphical menu can be customized using a theme definition file. This is a plain text file (usually named `theme.txt`). This file generally has two types of statements:\n- **global property**  \nThese are properties defined at the top level of our theme file definition. This syntax is: `title-text: \"Hello World\"`\n- **component property**  \nThey are created by prefixing the type of component with a ’+’ sign: `+ label { text=\"GRUB\" font=\"aqui 11\" color=\"#8FF\" }`\n\nTo get a list of all the properties and components available, you can check this [file](./theme-definition-properties.md).\n\n\n## 📹 Install Grub2-theme-preview\n\n[grub2-theme-preview](https://github.com/hartwork/grub2-theme-preview) is a very handy tool to test your new grub theme without having to reboot your machine every time you make a change.\n\nIt takes a theme folder, creates a temporary bootable image using `grub2-mkrescue` and launches that image in a virtual machine using KVM/QEMU.\n\nFirst we need to make sure to install these dependencies:\n\n```bash\nsudo apt install grub-common qemu-system-x86 ovmf mtools xorriso\n```\n\nTo install the package\n\n```bash\npip3 install --user grub2-theme-preview\n```  \n\n\u003e **🔹 NOTE 🔹** For this command to work, you obviously need to install `python3` and `python3-pip` on your system.  \n\nNow we can preview our grub theme with this command.\n\n```bash\ngrub2-theme-preview \u003cpath_of_theme_folder\u003e --resolution 1024x640\n```  \n\n\u003e **🔹 NOTE 🔹** By default the resolution of the QEMU virtual machine is `800x600`. That's why in the command we specified a resolution of `1024x640`. If you want to know which resolution are accepted you can check this [link](https://en.wikipedia.org/wiki/VESA_BIOS_Extensions#Linux_video_mode_numbers).\n\n\n## 🤯 Morphin Time\n\nNow that all the boring theory is done, we can get to the fun part.\n\n![galsen-grub](https://user-images.githubusercontent.com/46305144/185755552-6be51616-6f81-418c-a0d4-6f45249ba850.png)\n\nThis is what we want to achieve. We first need to create a folder for our theme and a theme definition file `theme.txt`\n\n```bash\nmkdir galsen_grub\ncd galsen_grub\ntouch theme.txt\n```\n\nNow let's add some properties to our theme definition file.\n\n\n### Global properties\n\nWe need to change the background image and the title of our GRUB.\n\nThe GRUB uses [PFF2 font format](http://grub.gibibit.com/New_font_format). `grub-mkfont` utility should be used to convert BDF, PCF or TTF fonts to PFF2 format. Output file should have `pf2` extension and should be placed inside the theme directory. The font used in this demo is [Permanent Marker](https://fonts.google.com/specimen/Permanent+Marker).\n\nTo convert the font, we input\n\n```bash\ngrub-mkfont PermanentMarker-Regular.ttf -o ./PermanentMarker_40.pf2 -v --size 40\n\n# Output of this command\nFont name: Permanent Marker Regular 40\nMax width: 50\nMax height: 45\nFont ascent: 44\nFont descent: 13\nNumber of glyph: 229\n```\n\n\u003e **🔹 NOTE 🔹** You need to run this command again to create another font with the size of 20\n\n\nIn the output we can see the font name. This will be useful in the theme definition file.\n\n\nThe last step is to copy the background file into the `galsen_grub` folder and add these line to `theme.txt`.\n\n```conf\ntitle-text: \"Grubu Kanaa\"\ntitle-color: \"#fff\"\ntitle-font:  \"Permanent Marker Regular 40\"\ndesktop-image: \"background.png\"\n```\n\n\u003e **🔹 NOTE 🔹** I named my image `background.png` but you can choose whatever you like for the name.  \n\n\nFor now your `galsen_grub` folder should like this.\n\n```bash\n./galsen_grub\n├── PermanentMarker_20.pf2\n├── PermanentMarker_40.pf2\n├── background.png\n└── theme.txt\n```\n\n### Boot Menu component\n\nNow come the most difficult part of this demo (or maybe not 😄), the boot menu. The tricky part is the **Styled Box Format** (we use it to set the background of our boot menu to multiple images).\n\n![image_slices](https://user-images.githubusercontent.com/46305144/185755821-f2da095a-c152-4026-88e3-bef0fb6be86c.gif)\n\nA styled box is composed of 9 rectangular (and potentially empty) regions, which are used to seamlessly draw the styled box on screen based on an image.\n\n![grub-theme-slices](https://user-images.githubusercontent.com/46305144/185755835-1a114b21-8349-47ec-ad3d-07ad80e04435.png)\n\nTo create these slices you can use something like **Inkscape** or **Figma**. (Maybe I'll record a video on how to do it on Figma).\n\nWe just need to add these lines to our theme definition file.\n\n```conf\n+ boot_menu {\n  left = 50%-300\n  top = 50%-160\n  width = 600\n  height = 320\n  menu_pixmap_style = \"boot_menu_*.png\"\n  item_color = \"#fff\"\n  item_spacing = 5\n  selected_item_color = \"#035AC4\"\n  scrollbar = true\n  item_height = 40\n  item_padding = 15\n  item_spacing = 15\n  item_font =  \"Permanent Marker Regular 20\"\n}\n```\n\nNow don't forget to copy the slices into the `galsen_grub` folder.\n\n\nBy now the structure of `galsen_grub` should like this.\n\n```bash\n./galsen_grub\n├── PermanentMarker_20.pf2\n├── PermanentMarker_40.pf2\n├── background.png\n├── boot_menu_c.png\n├── boot_menu_e.png\n├── boot_menu_n.png\n├── boot_menu_ne.png\n├── boot_menu_nw.png\n├── boot_menu_s.png\n├── boot_menu_se.png\n├── boot_menu_sw.png\n├── boot_menu_w.png\n└── theme.txt\n```\n\n### Progress Bar component\n\nThe final part is the progress bar, a horizontal bar that indicates the time remaining until the highlighted menu item is booted.\n\nWe will also another Stylex Box image for this component.\n\n```conf\n+ progress_bar {\n  id = \"__timeout__\"\n  width = 400\n  top = 90%\n  left = 50%-200\n  bar_style = \"progress_bar_*.png\"\n  highlight_style = \"progress_highlight_*.png\"\n  highlight_overlay = true\n}\n```\n\nThe final structure of `galsen_grub`\n\n```bash\n./galsen_grub\n├── PermanentMarker_20.pf2\n├── PermanentMarker_40.pf2\n├── background.png\n├── boot_menu_c.png\n├── boot_menu_e.png\n├── boot_menu_n.png\n├── boot_menu_ne.png\n├── boot_menu_nw.png\n├── boot_menu_s.png\n├── boot_menu_se.png\n├── boot_menu_sw.png\n├── boot_menu_w.png\n├── progress_bar_c.png\n├── progress_bar_e.png\n├── progress_bar_w.png\n├── progress_highlight_c.png\n├── progress_highlight_e.png\n├── progress_highlight_w.png\n└── theme.txt\n```\n\n\nTo preview the final result\n\n```bash\ngrub2-theme-preview . --resolution 1024x640\n```\n\n\u003e **🔹 NOTE 🔹**  To run this command you need to be inside of `galsen_grub` folder.\n\n\n## 🔚 Last step\n\nNow that we've written our theme and previewed it, we need to tell our system to use it.\n\nCreate a `themes` directory in `/boot/grub/`. This is where our themes will live (we can store multiple themes here).\n\n```bash\nsudo mkdir /boot/grub/themes\n```\n\nCopy our theme into the newly created folder\n\n```bash\nsudo mv galsen_grub /boot/grub/themes/\n```\n\nTo make the `bootloader` use our theme, we should add a `GRUB_THEME` parameter in file `/etc/default/grub`. We need to edit this file as **root**.\n\n```conf\nGRUB_THEME=/boot/grub/themes/galsen_grub/theme.txt\n```\n\nEvery time we update this file, we need to run `update-grub2` in order to regenerate the `bootloader` configuration file (`/boot/grub/grub.cfg`).\n\n```bash\nsudo update-grub2\n```\n\n\u003e **🔹 NOTE 🔹**  In case there is no `update-grub` in your system, you can run `grub2-mkconfig -o /boot/grub/grub.cfg`.\n\n\n## 📚 Resources\n\n- [Grub2 Documentation](https://www.gnu.org/software/grub/manual/grub/grub.html#Theme-file-format)\n- [Browse other GRUB themes](https://www.pling.com/browse?cat=109\u0026ord=latest)\n- [Getting started with GRUB Theming](https://github.com/VandalByte/grub-tweaks)\n\n\n## TODO\n\n- [x] Documentation\n- [x] Preview image of the GRUB\n- [x] Resource links\n- [x] Link to the slides\n- [ ] Make an install script\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndoy3m4n%2Fgalsen-grub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndoy3m4n%2Fgalsen-grub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndoy3m4n%2Fgalsen-grub/lists"}