GithubHelp home page GithubHelp logo

hartwork / grub2-theme-preview Goto Github PK

View Code? Open in Web Editor NEW
307.0 7.0 11.0 580 KB

:city_sunrise: Preview a full GRUB 2.x theme (or just a background image) using KVM / QEMU

Home Page: https://pypi.org/project/grub2-theme-preview/

Python 98.97% Makefile 1.03%
grub2 grub2-theme kvm python qemu cli-app debugging-tool python3

grub2-theme-preview's Introduction

pre-commit Run Python test suite

About

grub2-theme-preview came into life when I was looking around for available GRUB 2.x themes and wanted a way to quickly see a theme in action without rebooting real hardware.

It takes a theme folder (or just a single picture), creates a temporary bootable image using grub2-mkrescue and launches that image in a virtual machine using KVM/QEMU, all without root privileges.

grub2-theme-preview showing theme "gutsblack-archlinux"

(Showing theme gutsblack-archlinux)

Installation

To install the latest release from PyPI:

# pip install --user grub2-theme-preview

To install from a Git clone for development:

# pip install --user --editable .

Please make sure to install these non-PyPI dependencies as well:

  • grub-mkrescue of GRUB 2 (package grub-common on Debian and Ubuntu)
  • QEMUhypervisor that performs hardware virtualization
  • OVMF — EFI bios image for use with QEMU
  • mtoolscollection of utilities to access MS-DOS
  • xorriso of libisoburnfrontend which enables creation and expansion of the ISO format

Usage

# grub2-theme-preview --help
usage: grub2-theme-preview [-h] [--grub-cfg PATH] [--verbose]
                           [--resolution WxH] [--timeout SECONDS]
                           [--add TARGET=/SOURCE] [--version]
                           [--grub2-mkrescue COMMAND] [--qemu COMMAND]
                           [--xorriso COMMAND] [--no-kvm] [--debug]
                           [--plain-rescue-image]
                           PATH

positional arguments:
  PATH                  path of theme directory (or PNG/TGA image file) to
                        preview

optional arguments:
  -h, --help            show this help message and exit
  --grub-cfg PATH       path of custom grub.cfg file to use (default:
                        /boot/grub{2,}/grub.cfg)
  --verbose             increase verbosity
  --resolution WxH      set a custom resolution, e.g. 800x600
  --timeout SECONDS     set GRUB timeout in whole seconds or -1 to disable
                        (default: 30 seconds)
  --add TARGET=/SOURCE  make grub2-mkrescue add file(s) from /SOURCE to
                        /TARGET in the rescue image (can be passed multiple
                        times)
  --version             show program's version number and exit

command location arguments:
  --grub2-mkrescue COMMAND
                        grub2-mkrescue command (default: auto-detect)
  --qemu COMMAND        KVM/QEMU command (default: qemu-system-<machine>)
  --xorriso COMMAND     xorriso command (default: xorriso)

arguments related to invokation of QEMU/KVM:
  --display DISPLAY     pass "-display DISPLAY" to QEMU, see "man qemu" for
                        details (default: use QEMU's default display)
  --full-screen         pass "-full-screen" to QEMU
  --no-kvm              do not pass -enable-kvm to QEMU (and hence fall back
                        to acceleration "tcg" which is significantly slower
                        than KVM)
  --vga CARD            pass "-vga CARD" to QEMU, see "man qemu" for details
                        (default: use QEMU's default VGA card)

debugging arguments:
  --debug               enable debugging output
  --plain-rescue-image  use unprocessed GRUB rescue image with no theme
                        patched in; useful for checking if a plain GRUB rescue
                        image shows up a GRUB shell, successfully.

grub2-theme-preview's People

Contributors

animeshz avatar blameying avatar dependabot[bot] avatar dmadisetti avatar hartwork avatar mfaerevaag avatar natetronn avatar nikhilramolla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grub2-theme-preview's Issues

Fedora 22: Using default fedora image does result in no background

Hey,

when I try to

./grub2-theme-preview --verbose --image /usr/share/backgrounds/f22/default/normalish/f22.png

on fedora 22. I get this:
screenshot from 2015-07-17 00-02-04

I should be seeing something with this file in the background:
f22

My verbose output:

 $ ./grub2-theme-preview --verbose --image /usr/share/backgrounds/f22/default/normalish/f22.png 
# grub2-mkrescue --xorriso xorriso --output /tmp/tmpS_VeRv/grub2_theme_demo.img  boot/grub/grub.cfg=/tmp/tmpS_VeRv/grub.cfg  boot/grub/themes/DEMO.png=/usr/share/backgrounds/f22/default/normalish/f22.png
 xorriso 1.4.0 : RockRidge filesystem manipulator, libburnia project.

 Drive current: -outdev 'stdio:/tmp/tmpS_VeRv/grub2_theme_demo.img'
 Media current: stdio file, overwriteable
 Media status : is blank
 Media summary: 0 sessions, 0 data blocks, 0 data, 1685m free
 Added to ISO image: directory '/'='/tmp/grub.skLtkX'
 xorriso : UPDATE : 344 files added in 1 seconds
 Added to ISO image: file '/boot/grub/grub.cfg'='/tmp/tmpS_VeRv/grub.cfg'
 Added to ISO image: file  '/boot/grub/themes/DEMO.png'='/usr/share/backgrounds/f22/default/normalish/f22.png'
 xorriso : UPDATE : 346 files added in 1 seconds
 xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/lib/grub/i386-pc/boot_hybrid.img'
 ISO image produced: 6260 sectors
 Written to medium : 6260 sectors at LBA 0
 Writing to 'stdio:/tmp/tmpS_VeRv/grub2_theme_demo.img' completed successfully.

 INFO: Please give GRUB a moment to show up in QEMU...
 # qemu-system-x86_64 -drive  file=/tmp/tmpS_VeRv/grub2_theme_demo.img,index=0,media=disk,format=raw

Custom Fonts Not Loading

I think this is a different issue than referenced at #19 as when I enter the grub shell and run lsfonts I only get the entry Unifont Regular 16.
I have a custom font defined in /etc/default/grub with GRUB_FONT=/boot/grub/fonts/Font1.pf2 and another font called for in my theme.txt as the item_font = "Font2 14". I have tried with and without a second line in /etc/default/grub for GRUB_FONT=/boot/grub/fonts/Font2.pf2. When I boot the system for real and enter the grub shell lsfonts shows Font1 loaded.

Feature Request: Please add support for custom configs

Features request:

Please add support for custom configs files. For example, custom.cfg, liveiso.cfg etc. Then we could do the following wildcard match for .cfg file name:

grub2-theme-preview --grub-cfg /boot/grub{2,}/*.cfg /usr/share/grub/themes/manjaro

And or just pass multiple paths directly.

And or there could be a --grub-custom-cfg flag, where we pass one or multiple custom config paths.

Thanks!

Cannot get any preview without error

Hello, I've made this SLiM theme and intend to make a GRUB2 theme of it... So, I've tried to preview GRUB2 default theme before starting, and I am getting this error:

$ grub2-theme-preview --grub-cfg ./grub.cfg ./starfield
INFO: Appending to fonts to load: dejavu_10.pf2
INFO: Appending to fonts to load: dejavu_12.pf2
INFO: Appending to fonts to load: dejavu_14.pf2
INFO: Appending to fonts to load: dejavu_16.pf2
INFO: Appending to fonts to load: dejavu_bold_14.pf2
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/grub2-theme-preview", line 6, in <module>
    main()
  File "/usr/lib64/python2.7/site-packages/grub2_theme_preview/cli.py", line 245, in main
    _run(run_command, options.verbose)
  File "/usr/lib64/python2.7/site-packages/grub2_theme_preview/cli.py", line 40, in _run
    subprocess.call(cmd, stdout=stdout, stderr=stdout)
  File "/usr/lib64/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib64/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I have previously copied the files in order to get write permission. I cannot understand what's wrong with that output.

Timeout / progress notification not showing up

Hi,

i created a grub2-theme for gentoo, but the timeout notification shows not up in QEMU, neither the progrees_bar nor the quick test with the circular_progress. The same theme with Grub2 on my real machine shows me the progress_bar.So, is the timeout notification working with QEMU at all?

You can have a look at my repo:
https://github.com/vitalogy/grub2-theme-gentoo

The Screenshot is taken from QEMU, as you can see, there is no progress_bar.

And thanks for this little programm, it saves a lot of time.

[1.4.2] Stuck on "Booting from Hard Disk" on host with EFI

Hi, I'm unable to run it on Lubuntu 18.04, I did as follows:

sudo su
pip install grub2_theme_preview
apt install xorriso

The script only seemed to complain about xorriso as I already seem to have qemu (or at least I have 60+ commands starting with qemu-)

And after running what the terminal in the image shows, I got stuck in this.

2020-06-27-203559_946x627_scrot

Do you have any ideas?

ERROR: Command "grub-mkrescue" of Grub 2.x not found

Hi. Looks like a good tool but had difficulty running.
Did....
grub2-theme-preview /boot/grub2/themes/Breeze
and got.....
ERROR: Command "grub-mkrescue" of Grub 2.x not found

grub2-mkrescue is the command on my Fedora 33 setup so I did....
alias grub-mkrescue=grub2-mkrescue
That aliaslink is now recognised for issuing grub-mkrescue from terminal but still I get...
ERROR: Command "grub-mkrescue" of Grub 2.x not found when I run grub2-theme-preview /boot/grub2/themes/Breeze

Error `mcopy` invocation failed: `mcopy: No directory slots`

OS: Artix
using pip version

 grub2-theme-preview --grub-cfg ./grub.cfg --verbose --debug Downloads/grub/primitivistical-grub-v0.2/Primitivistical/

>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
loadfont $prefix/fonts/unicode.pf2
insmod all_video
insmod gfxterm
insmod png
insmod tga
insmod jpeg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="Artix Linux, mit Linux linux-zen"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

set menu_color_normal=light-blue/black
set menu_color_highlight=light-cyan/blue

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod btrfs
set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
else
  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
fi
    font="/@/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=1024x768,800x600
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=de_DE
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
insmod part_gpt
insmod btrfs
set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
else
  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
fi
insmod gfxmenu
insmod png
set theme=($root)/@/boot/grub/themes/Primitivistical/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=3
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=3
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/01_grub-customizer_menu_color_helper ###
### END /etc/grub.d/01_grub-customizer_menu_color_helper ###

### BEGIN /etc/grub.d/10_linux_proxy ###



if [ "x$default" = 'Artix Linux, mit Linux linux-zen' ]; then default='Advanced options for Artix Linux>Artix Linux, mit Linux linux-zen'; fi;
menuentry "Artix Linux, mit Linux linux-zen" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-zen-advanced-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux-zen wird geladen …'
		linux	/@/boot/vmlinuz-linux-zen root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux-zen.img
}
### END /etc/grub.d/10_linux_proxy ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (auf /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-3455-753F' {
	insmod part_gpt
	insmod fat
	set root='hd0'  # replaced by grub2-theme-preview, was 'hd0,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  3455-753F
	else
	  search --no-floppy --fs-uuid --set=root 3455-753F
	fi
	chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/33_linux_proxy ###
submenu "Erweiterte Optionen für Artix Linux"{
menuentry "Artix Linux" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-b80e6511-2de5-41bb-a550-8961913b1ceb' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod btrfs
	set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
	else
	  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
	fi
	echo	'Linux linux-zen wird geladen …'
	linux	/@/boot/vmlinuz-linux-zen root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
	echo	'Initiale Ramdisk wird geladen …'
	initrd	/@/boot/initramfs-linux-zen.img
}
menuentry "Artix Linux, mit Linux linux" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux wird geladen …'
		linux	/@/boot/vmlinuz-linux root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux.img
}
menuentry "Artix Linux, with Linux linux-zen (fallback initramfs)" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-zen-fallback-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux-zen wird geladen …'
		linux	/@/boot/vmlinuz-linux-zen root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux-zen-fallback.img
}
menuentry "Artix Linux, with Linux linux (fallback initramfs)" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux wird geladen …'
		linux	/@/boot/vmlinuz-linux root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux-fallback.img
}
menuentry "Artix Linux, mit Linux linux-lts" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-advanced-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux-lts wird geladen …'
		linux	/@/boot/vmlinuz-linux-lts root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux-lts.img
}
menuentry "Artix Linux, with Linux linux-lts (fallback initramfs)" --class artix --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-fallback-b80e6511-2de5-41bb-a550-8961913b1ceb' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		set root='hd0'  # replaced by grub2-theme-preview, was 'hd2,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
		else
		  search --no-floppy --fs-uuid --set=root b80e6511-2de5-41bb-a550-8961913b1ceb
		fi
		echo	'Linux linux-lts wird geladen …'
		linux	/@/boot/vmlinuz-linux-lts root=UUID=b80e6511-2de5-41bb-a550-8961913b1ceb rw rootflags=subvol=@ net.ifnames=0 verbose resume=UUID=4296f87c-4437-40e6-b723-f856139bb9e8
		echo	'Initiale Ramdisk wird geladen …'
		initrd	/@/boot/initramfs-linux-lts-fallback.img
}
}
### END /etc/grub.d/33_linux_proxy ###

### BEGIN /etc/grub.d/34_linux_xen ###
### END /etc/grub.d/34_linux_xen ###

### BEGIN /etc/grub.d/35_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
	fwsetup
}
### END /etc/grub.d/35_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/42_snapshots-btrfs ###
submenu 'Artix Linux snapshots' {
    configfile "${prefix}/grub-btrfs.cfg"
}
### END /etc/grub.d/42_snapshots-btrfs ###

### BEGIN /etc/grub.d/60_memtest86+ ###
if [ "${grub_platform}" == "pc" ]; then
    menuentry "Memory Tester (memtest86+)" --class memtest86 --class gnu --class tool {
        search --fs-uuid --no-floppy --set=root --hint-bios=hd2,gpt3 --hint-efi=hd2,gpt3 --hint-baremetal=ahci2,gpt3  b80e6511-2de5-41bb-a550-8961913b1ceb
        linux16 /@/boot/memtest86+/memtest.bin 
    }
fi
### END /etc/grub.d/60_memtest86+ ###

submenu 'Reboot / Shutdown' {
    menuentry Reboot { reboot }
    menuentry Shutdown { halt }
}

set default=0
set timeout=30
terminal_output gfxterm
set theme=$prefix/themes/DEMO/theme.txt
>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

INFO: Found OVMF image at '/usr/share/edk2-ovmf/x64/OVMF_CODE.fd'.
# grub-mkrescue --directory=/usr/lib/grub/x86_64-efi --xorriso xorriso --output /tmp/tmpu77ye3cn/grub2_theme_demo.img boot/grub/grub.cfg=/tmp/tmpu77ye3cn/grub.cfg boot/grub/themes/DEMO/=/home/<user>/Downloads/grub/primitivistical-grub-v0.2/Primitivistical
mcopy: No directory slots
grub-mkrescue: Fehler: `mcopy` invocation failed
.
Traceback (most recent call last):
  File "/home/<user>/.local/lib/python3.9/site-packages/grub2_theme_preview/__main__.py", line 464, in main
    _inner_main(options)
  File "/home/<user>/.local/lib/python3.9/site-packages/grub2_theme_preview/__main__.py", line 432, in _inner_main
    raise OSError(errno.ENOENT, '%s failed to create the rescue image' % command)
FileNotFoundError: [Errno 2] grub-mkrescue failed to create the rescue image
ERROR: [Errno 2] grub-mkrescue failed to create the rescue image

Doesn't work on Ubuntu 16.04/xenial

Thank you for your tool, but unfortunately it doesn't work for me

user@host:~$ grub2-theme-preview --grub2-mkrescue grub-mkrescue --verbose /boot/grub/themes/Fallout/
INFO: Appending to fonts to load: fixedsys-regular-24.pf2
INFO: Appending to fonts to load: fixedsys-regular-32.pf2
# grub-mkrescue --xorriso xorriso --output /tmp/tmphfYhW9/grub2_theme_demo.img boot/grub/grub.cfg=/tmp/tmphfYhW9/grub.cfg boot/grub/themes/DEMO/=/boot/grub/themes/Fallout
xorriso 1.4.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/tmp/tmphfYhW9/grub2_theme_demo.img'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 7532m free
Added to ISO image: directory '/'='/tmp/grub.rsdceU'
xorriso : UPDATE : 278 files added in 1 seconds
Added to ISO image: file '/boot/grub/grub.cfg'='/tmp/tmphfYhW9/grub.cfg'
Added to ISO image: directory '/boot/grub/themes/DEMO'='/boot/grub/themes/Fallout'
xorriso : UPDATE : 324 files added in 1 seconds
ISO image produced: 5213 sectors
Written to medium : 5213 sectors at LBA 0
Writing to 'stdio:/tmp/tmphfYhW9/grub2_theme_demo.img' completed successfully.

INFO: Please give GRUB a moment to show up in QEMU...
# qemu-system-x86_64 -drive file=/tmp/tmphfYhW9/grub2_theme_demo.img,index=0,media=disk,format=raw
warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]

And unfortunately all I can see is
image

And if I create img for QEMU by hands (converting img from vmdk) everything works.

I can attach generated *.img file if needed.

How to use it correctly?

I have executed as follows:

  1. As a normal user on my Arch with bspWM:
    grub2-theme-preview ~/Downloads/Graphite-gtk-theme --grub-cfg ~/Downloads/grub.cfg --debug

  2. As root user:
    grub2-theme-preview /usr/share/grub/themes/Graphite-gtk-theme --debug

However, they don't work. Could you help me with any ideas please.

Seems to work, but no boot menu shown

Trying out your theme previewer and it seems to be working as expected but never shows boot screen ..

usage:
/grub2-theme-preview --verbose /path_to_my/theme/name

Output:

INFO: Appending to fonts to load: DejaVuSansMono-08.pf2
INFO: Appending to fonts to load: DejaVuSansMono-22.pf2
INFO: Appending to fonts to load: FreeSans-22.pf2
# grub-mkrescue --directory=/usr/lib/grub/x86_64-efi --xorriso xorriso --output /tmp/tmpxqgu_eyx/grub2_theme_demo.img boot/grub/themes/DEMO/=/boot/grub/themes/blue-tiger-fractal
xorriso 1.5.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/tmp/tmpxqgu_eyx/grub2_theme_demo.img'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data,  162g free
Added to ISO image: directory '/'='/tmp/grub.ttA5OF'
xorriso : UPDATE :     289 files added in 1 seconds
Added to ISO image: directory '/boot/grub/themes/DEMO'='/boot/grub/themes/blue-tiger-fractal'
xorriso : UPDATE :     384 files added in 1 seconds
ISO image produced: 5632 sectors
Written to medium : 5632 sectors at LBA 0
Writing to 'stdio:/tmp/tmpxqgu_eyx/grub2_theme_demo.img' completed successfully.

INFO: Please give GRUB a moment to show up in QEMU...
# qemu-system-x86_64 -m 256 -drive file=/tmp/tmpxqgu_eyx/grub2_theme_demo.img,index=0,media=disk,format=raw -bios /usr/share/OVMF/OVMF_CODE.fd
VNC server running on 127.0.0.1:5900

It stays there and nothing else happens.
I am running Linux Mint 20.
Is there something I am missing?
I do thank you

Out of memory error

QEMU uses 128MB of memory by default. Without increasing this value, I can't test my themes

grub2-theme-preview TestTheme/:
Default resolution
After changing the resolution to 1080p, I see an out of memory error before getting to the menu
grub2-theme-preview --resolution 1920x1080 TestTheme/:
1080p
When I launch the image manually, assigning 256MB of memory, everything works perfectly
qemu-system-x86_64 -drive file=/tmp/tmpp3to5qpq/grub2_theme_demo_copy.img,index=0,media=disk,format=raw -bios /usr/share/edk2-ovmf/x64/OVMF_CODE.fd -m 256M:
1080p, 256M
(image used)

Whether it works - it also depends on the image used. For example, this (uncropped, in case anyone is interested) image works with the default settings, even though it is bigger by 0.3MB. It still doesn't work at 1920x1080 without increasing RAM
grub2-theme-preview TestTheme/:
Default resolution, alt image
In case you need that theme for testing for some reason: TestTheme.zip

I think that you need to add an argument that allows setting the amount of memory and/or raise the default.

Important: I use the AUR package.
EDIT: tested with the latest release from PyPI, the issue still exists

[1.4.3] Custom font not showing up

Following discussion from #18 in which unicode font was shown instead of the theme's custom one.
I think I found why it happens.
The last loadfont of the resulting grub.cfg is the font that gets to be used.
In _make_grub_cfg_load_our_theme the prolog list loads the correct font before appending the source grub.cfg.
The source grub.cfg seems to overwrite that one with the default unicode. It also tries to load the custom font as well, but I guess the path in the source grub.cfg may be incorrect from the qemu point of view, and so it keeps the unicode font.

In my case hardcoding the element "loadfont $prefix/themes/DEMO/googlesans.pf2" inside epilog_chunks solves it.

To summarize:

source grub.cfg

loadfont $font # Loads unicode font
loadfont ($root)/boot/grub/themes/Matter/googlesans.pf2 # Loads custom font from theme

resulting non-working grub.cfg (current)

# Prolog
loadfont $prefix/themes/DEMO/googlesans.pf2

# Contents of source grub.cfg
loadfont $font # Loads unicode font
loadfont ($root)/boot/grub/themes/Matter/googlesans.pf2 # Loads custom font from theme, probably an invalid path

# Epilog
...

resulting working grub.cfg (proposed)

# Prolog
...

# Contents of source grub.cfg
loadfont $font # Loads unicode font
loadfont ($root)/boot/grub/themes/Matter/googlesans.pf2 # Loads custom font from theme, probably an invalid path

# Epilog
loadfont $prefix/themes/DEMO/googlesans.pf2

I would make a PR, but don't really have the time to read too much into the script to check it does not break other things.

Auto-detect grub2-mkrescue named grub-mkrescue

for example, in archlinux grub2 is packaged with name grub, also all executable files in package grub begin with string "grub-". user should make a link manually to keep script run correctly.
in a word grub2-mkrescue is named by grub-mkrescue in some distro, but the script can not identify it.

~ » pacman -Ql grub | grep -oP '(?<=bin/).+$'
grub-bios-setup
grub-editenv
grub-file
grub-fstest
grub-glue-efi
grub-install
grub-kbdcomp
grub-macbless
grub-menulst2cfg
grub-mkconfig
grub-mkfont
grub-mkimage
grub-mklayout
grub-mknetdir
grub-mkpasswd-pbkdf2
grub-mkrelpath
grub-mkrescue
grub-mkstandalone
grub-mount
grub-ofpathname
grub-probe
grub-reboot
grub-render-label
grub-script-check
grub-set-default
grub-sparc64-setup
grub-syslinux2cfg

Use Custom Config

Apologies if there's already a flag for this, but I couldn't seem to work it out myself:
The preview always displays with the same Gentoo, Debian, Memtest options. Is there a way to get it to read from my system's own grub.cfg file, such that I can quickly preview my custom menu changes?

Address QEMU warning "Image format was not specified" (volunteers welcome)

[..]
# qemu-system-x86_64 -hda /tmp/tmpS3A839/grub2_theme_demo.img
WARNING: Image format was not specified for '/tmp/tmpS3A839/grub2_theme_demo.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

[EndeavourOS] ERROR: [Errno 2] OVMF image file "/usr/share/OVMF/OVMF_CODE.fd" (provided by package "ovmf") missing, please install

Installed grub2-theme-preview from the AUR but it doesn't seem to work for me. I already have all of the dependencies including ovmf installed but it gives me this error:
# grub2-theme-preview --verbose /boot/grub/themes/EndeavourOS INFO: Appending to fonts to load: unifont-regular-16.pf2 ERROR: [Errno 2] OVMF image file "/usr/share/OVMF/OVMF_CODE.fd" (provided by package "ovmf") missing, please install

Option "--resolution=" does not work

When i use the --resolution option it does not work. I compared both outputs with --debug and noticed that your program puts the "set gfxmode=" to the top. But down the line the original "set gfxmode=auto" is still there! So it sets it to my resolution, but further down the line it is set back to auto..
Maybe it would be better if your program first search for an existing, and if found then replace it. If not found, then set to the top were it is now.

screenshot-jpg-JPEG-afbeelding-1167-×-591-pixels-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.