PDA

View Full Version : [ubuntu] grub2 add splash.



penduleum
February 15th, 2011, 08:00 PM
hey all.

After reading a while in this tread:
http://ubuntuforums.org/showthread.php?t=30341

i disided to do some tweaking in grub2.

I have got the image working, not the same way as the tutorial, but it works.

When i add the image (extention .tga) to the section wallpaper in 05_debian_theme, and update grub, it works. But i have some kind of a problem that i cant understand...

and that is this section:

c/p from 05_debian_theme:


# this allows desktop-base to override our settings
f=/usr/share/desktop-base/grub_background.sh
if test -e ${f} ; then
. ${f}
else
WALLPAPER="/usr/share/images/grub/Sparkler.tga"
COLOR_NORMAL="black/red"
COLOR_HIGHLIGHT="black/green"
fi

set_mono_theme()
{
cat << EOF
set menu_color_normal=green/brown
set menu_color_highlight=black/black
EOF
}

the part:

COLOR_NORMAL="black/red"
COLOR_HIGHLIGHT="black/green"


gives me some headic...
This part puts the background (wallpaper) complete to whatever i have put in there.. (red blue brown ect).

If i remove that part, i get the *.tga wallpaper, but cant read the menu enterys, and it gives me a syntax error of some kind (cant read it).

So, what can i do to resolve this problem?

Here is the complete 05_debian_theme and grub.cfg:

05_debian_theme:


#!/bin/sh -e

. /usr/lib/grub/grub-mkconfig_lib

# this allows desktop-base to override our settings
f=/usr/share/desktop-base/grub_background.sh
if test -e ${f} ; then
. ${f}
else
WALLPAPER="/usr/share/images/grub/Sparkler.tga"
COLOR_NORMAL="black/red"
COLOR_HIGHLIGHT="black/green"
fi

set_mono_theme()
{
cat << EOF
set menu_color_normal=green/brown
set menu_color_highlight=black/black
EOF
}

# check for usable backgrounds
use_bg=false
for output in ${GRUB_TERMINAL_OUTPUT}; do
if [ "$output" = "gfxterm" ] ; then
for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
if is_path_readable_by_grub $i ; then
bg=$i
case ${bg} in
*.png) reader=png ;;
*.tga) reader=tga ;;
*.jpg|*.jpeg) reader=jpeg ;;
esac
if test -e /boot/grub/${reader}.mod ; then
echo "Found background image: `basename ${bg}`" >&2
use_bg=true
break
fi
fi
done
break
fi
done

# set the background if possible
if ${use_bg} ; then
prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
cat << EOF
insmod ${reader}
if background_image `make_system_path_relative_to_its_root ${bg}` ; then
set color_normal=${COLOR_NORMAL}
set color_highlight=${COLOR_HIGHLIGHT}
else
EOF
fi

# otherwise, set a monochromatic theme for Ubuntu
if ${use_bg} ; then
set_mono_theme | sed -e "s/^/ /g"
echo "fi"
else
set_mono_theme
fi

Ofcourse, i do a grup update so that the changes have there effect....
(

grub.cfg:



#
# 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 ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="4"
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 recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
insmod vbe
insmod vga
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=1280x1024
load_video
insmod gfxterm
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
insmod tga
if background_image /usr/share/images/grub/Sparkler.tga ; then
set color_normal=
set color_highlight=
else
set menu_color_normal=green/brown
set menu_color_highlight=red/blue
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.35-22-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
linux /boot/vmlinuz-2.6.35-22-generic root=UUID=7284759a-64ac-4f93-b89e-8a3a0808e229 ro splash vga=795 quiet splash
initrd /boot/initrd.img-2.6.35-22-generic
}
menuentry 'Ubuntu, with Linux 2.6.35-22-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
echo 'Loading Linux 2.6.35-22-generic ...'
linux /boot/vmlinuz-2.6.35-22-generic root=UUID=7284759a-64ac-4f93-b89e-8a3a0808e229 ro single splash vga=795
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.35-22-generic
}
### END /etc/grub.d/10_linux ###

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

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set 7284759a-64ac-4f93-b89e-8a3a0808e229
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 62bee1dbbee1a82d
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### 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 $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###


My question is, how can i activate the wallpaper that i have selected, and that whit colloured menus. Whitout the problem that the wallpaper get replaced by any of the collors i put in there...

thx for the help!!

Krytarik
February 17th, 2011, 09:57 PM
Your 05_debian_theme looks different than mine in some other places, this is the default one:

#!/bin/bash -e

source /usr/lib/grub/grub-mkconfig_lib

# this allows desktop-base to override our settings
f=/usr/share/desktop-base/grub_background.sh
if test -e ${f} ; then
source ${f}
else
WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
COLOR_NORMAL="black/black"
COLOR_HIGHLIGHT="magenta/black"
fi

set_mono_theme()
{
cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
EOF
}

# check for usable backgrounds
use_bg=false
if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
if is_path_readable_by_grub $i ; then
bg=$i
case ${bg} in
*.png) reader=png ;;
*.tga) reader=tga ;;
*.jpg|*.jpeg) reader=jpeg ;;
esac
if test -e /boot/grub/${reader}.mod ; then
echo "Found background image: `basename ${bg}`" >&2
use_bg=true
break
fi
fi
done
fi

# set the background if possible
if ${use_bg} ; then
prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
cat << EOF
insmod ${reader}
if background_image `make_system_path_relative_to_its_root ${bg}` ; then
set color_normal=${COLOR_NORMAL}
set color_highlight=${COLOR_HIGHLIGHT}
else
EOF
fi

# otherwise, set a monochromatic theme for Ubuntu
if ${use_bg} ; then
set_mono_theme | sed -e "s/^/ /g"
echo "fi"
else
set_mono_theme
fiAside from this I don't get why your setup results in the mentioned way.

Try setting up your background image via "/etc/default/grub", following this guide:
https://help.ubuntu.com/community/Grub2#Splash%20Images%20and%20Theming

You may also use my "06_ubuntu_theme" to overide the "05_debian_theme", I have it from this package, along with the (purple) image of course: http://gnome-look.org/content/show.php/Grub2+Splash+Image+?content=125657

It searches in the specified locations for any images named "splash-image.png" or "splash-image.tga".


#!/bin/bash -e

source /usr/lib/grub/grub-mkconfig_lib

set_mono_theme()
{
cat << EOF
set menu_color_normal=white/black
set menu_color_highlight=white/light-gray
EOF
}

# check for usable backgrounds
use_bg=false
if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
for i in {/boot/grub,/usr/share/images/desktop-base}/splash-image.{png,tga} ; do
if is_path_readable_by_grub $i ; then
bg=$i
case ${bg} in
*.png) reader=png ;;
*.tga) reader=tga ;;
*.jpg|*.jpeg) reader=jpeg ;;
esac
if test -e /boot/grub/${reader}.mod ; then
echo "Found Debian background: `basename ${bg}`" >&2
use_bg=true
break
fi
fi
done
fi

# set the background if possible
if ${use_bg} ; then
prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
cat << EOF
insmod ${reader}
if background_image `make_system_path_relative_to_its_root ${bg}` ; then
set color_normal=white/black
set color_highlight=white/light-gray
else
EOF
fi

# otherwise, set a monochromatic theme for Ubuntu
if ${use_bg} ; then
set_mono_theme | sed -e "s/^/ /g"
echo "fi"
else
set_mono_theme
fi

drs305
February 17th, 2011, 10:14 PM
The second entry in each setting should be set to "black". This value is considered "transparent" by Grub2.

So:

COLOR_NORMAL="black/red"
COLOR_HIGHLIGHT="black/green"

Unselected: Black text, with the the rest of the screen red except the highlighted line;
Selected/Highlighted: Black text, and the rest of the selected line green.

You want to make the second entry black on each line. The sparkler image, if I recall, has a lot of colors, so the color you pick for the first value must be a shade visible on the sparkler background. It's generally dark, so something like this might work:

COLOR_NORMAL="yellow/black"
COLOR_HIGHLIGHT="green/black"

I personally use "light-gray/black" for the COLOR_NORMAL value - I can see it but the highlighted color really stands out then. But of course it would depend on the background color.

Krytarik
February 17th, 2011, 11:18 PM
The second entry in each setting should be set to "black". This value is considered "transparent" by Grub2.
OMG, I obviously overlooked that part of the guide!

But the settings you described would be the other way around, "highlight" means selected menu entry!?

EDIT: And I would also choose a (not transparent) background color for the highlighted entry.

drs305
February 17th, 2011, 11:20 PM
OMG, I obviously overlooked that part of the guide!

But the settings you described would be the other way around, "highlight" means selected menu entry!?

Yes. Advice dyslexia I suppose. Or would it be color blindness? ;-)

In either case, I'll exchange the values.

Thanks.