Bug#588884: Convert SVG file

Frank Lin PIAT fpiat at klabs.be
Tue Jul 13 05:04:12 UTC 2010


Package: grub-pc
Version: 1.98~20100101-1
Severity: normal

[re-submitting this bug, which was originally sent to #560978 by mistake]


Assuming that the background image provided is a .svg, I have added the
following snippet in /etc/grub.d/05_debian_theme to convert the svg into
a png at the resolution specified GRUB_GFXMODE.

This snippets certainly needs some improvements/a better integration
with grub.

Franklin


# Convert .svg files
case $WALLPAPER in
	*.svg)
	svgfmt=$(echo $GRUB_GFXMODE | sed -n -e 's/^\(\w*\)x\(\w*\)$/-w \1 -h \2/p')

	[ ! "$svgfmt" ] && svgfmt="-w 640 -h 480"
	if which rsvg-convert > /dev/null; then
		rsvg-convert -f png $svgfmt $WALLPAPER -o /boot/grub/auto-converted.png
		WALLPAPER=/boot/grub/auto-converted.png
	fi
	;;
esac



### BEGIN /etc/grub.d/05_debian_theme ###
#!/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"
  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-wallpaper.svg"
  COLOR_NORMAL="black/black"
  COLOR_HIGHLIGHT="magenta/black"
fi

set_blue_theme()
{
  cat << EOF
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
EOF
}

# Convert .svg files
case $WALLPAPER in
	*.svg)
	svgfmt=$(echo $GRUB_GFXMODE | sed -n -e 's/^\(\w*\)x\(\w*\)$/-w \1 -h \2/p')

	[ ! "$svgfmt" ] && svgfmt="-w 640 -h 480"
	if which rsvg-convert > /dev/null; then
		rsvg-convert -f png $svgfmt $WALLPAPER -o /boot/grub/auto-converted.png
		WALLPAPER=/boot/grub/auto-converted.png
	fi
	;;
esac

# 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 the traditional Debian blue theme
if ${use_bg} ; then
  set_blue_theme | sed -e "s/^/  /g"
  echo "fi"
else
  set_blue_theme
fi
### END /etc/grub.d/05_debian_theme ###








More information about the Pkg-grub-devel mailing list