#!/bin/sh -e

# Include the GRUB helper library for grub-mkconfig.
. "/usr/share/grub/grub-mkconfig_lib"

# ====== SimulaMet theme =======================================================
theme="SimulaMet Desktop"
image="/boot/SimulaMet/Lindøya"
suffix=".jpeg"

background="$image-1024x768$suffix"   # VGA resolution is fallback
resolutions=`grep "^GRUB_GFXMODE=" /etc/default/grub | sed -e "s/GRUB_GFXMODE=//g" -e "s/[,\"]/ /g"`
for resolution in $resolutions ; do
   if [ -e "$image-$resolution$suffix" ] ; then
      background="$image-$resolution$suffix"
      break
   fi
done

# ====== Apply the theme ====================================================
echo >&2 "Using $theme theme from $background!"

echo "insmod jpeg"   # Load JPEG reader!
echo "if background_image `make_system_path_relative_to_its_root "$background"`; then"
echo "   set menu_color_normal=yellow/black"
echo "   set menu_color_highlight=red/light-gray"
echo "   set color_normal=yellow/black"
echo "fi"
