#! /bin/sh -e

prefix=/usr
exec_prefix=/usr
bindir=/usr/bin
libdir=/usr/lib64
datadir=/usr/share
. ${datadir}/grub/grub-mkconfig_lib

# check for usable backgrounds
use_bg=false
if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] && [ "x$GRUB_WALLPAPER" != "x" ]; then
  for i in ${datadir}/grub/`basename $GRUB_WALLPAPER` $GRUB_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 ${libdir}/grub/i386-pc/${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}
EOF
fi

GRUB_COLOR_NORMAL=${GRUB_COLOR_NORMAL:=white/black}
GRUB_COLOR_HIGHLIGHT=${GRUB_COLOR_HIGHLIGHT:=black/light-gray}

cat << EOF
set color_normal=$GRUB_COLOR_NORMAL
set color_highlight=$GRUB_COLOR_HIGHLIGHT
EOF
