Share Pastebin
Guest
Public paste!

drs305

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 1.60 KB | Hits: 218 | Expires: Never
Copy text to clipboard
  1. #!/bin/bash -e
  2.  
  3. source /usr/lib/grub/grub-mkconfig_lib
  4.  
  5. # this allows desktop-base to override our settings
  6. f=/usr/share/desktop-base/grub_background.sh
  7. if test -e ${f} ; then
  8.   source ${f}
  9. else
  10. #  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
  11. #  COLOR_NORMAL="black/black"
  12. #  COLOR_HIGHLIGHT="magenta/black"
  13. WALLPAPER="/mnt/data/docs2/computer/backgrounds/grub.backgrounds/bg_earth.1024x768.scaled.png"
  14.   COLOR_NORMAL="light-gray/black"
  15.   COLOR_HIGHLIGHT="green/black"
  16. fi
  17.  
  18. set_mono_theme()
  19. {
  20.   cat << EOF
  21. set menu_color_normal=white/black
  22. set menu_color_highlight=black/light-gray
  23. EOF
  24. }
  25.  
  26. # check for usable backgrounds
  27. use_bg=false
  28. if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
  29.   for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
  30.     if is_path_readable_by_grub $i ; then
  31.       bg=$i
  32.       case ${bg} in
  33.         *.png)          reader=png ;;
  34.         *.tga)          reader=tga ;;
  35.         *.jpg|*.jpeg)   reader=jpeg ;;
  36.       esac
  37.       if test -e /boot/grub/${reader}.mod ; then
  38.         echo "Found background image: `basename ${bg}`" >&2
  39.         use_bg=true
  40.         break
  41.       fi
  42.     fi
  43.   done
  44. fi
  45.  
  46. # set the background if possible
  47. if ${use_bg} ; then
  48.   prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
  49.   cat << EOF
  50. insmod ${reader}
  51. if background_image `make_system_path_relative_to_its_root ${bg}` ; then
  52.   set color_normal=${COLOR_NORMAL}
  53.   set color_highlight=${COLOR_HIGHLIGHT}
  54. else
  55. EOF
  56. fi
  57.  
  58. # otherwise, set a monochromatic theme for Ubuntu
  59. if ${use_bg} ; then
  60.   set_mono_theme | sed -e "s/^/  /g"
  61.   echo "fi"
  62. else
  63.   set_mono_theme
  64. fi