Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Grub 2 Drop-In Backgrounds & Font Selection

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Grub 2 Drop-In Backgrounds & Font Selection

    This page has been migrated to the Ubuntu Community Documentation site. For the most up-to-date information, please visit:
    https://help.ubuntu.com/community/Grub2/Displays

    The above page is a sub-page of the main community documentation regarding https://help.community/Grub2.

    Thank you to all the users who posted in these threads and expanded our knowledge of Grub 2 since it's introduction.

    A thread for discussion of the wiki can be found at http://ubuntuforums.org/showthread.php?p=12073029

    Support threads regarding the wiki and it's content should be created in a suitable forum.

    ----

    First, a disclaimer. Grub 1.99 RC1 will be distributed with Ubuntu 11.04, Natty Narwhal. Dropping a background image into /boot/grub will not work with Grub 1.98 or earlier, but there are other methods discussed in this guide that will. All Grub 2 users can use this guide to help select font & background colors.

    Users looking for information about themes will not find it in this thread. Sorry.

    GRUB 1.99 Background Images

    Copy a .jpg, .png or .tga image to /boot/grub, update Grub, and you now have a Grub menu background. If you haven't previously set up an image or theme, it can be that simple!

    Ubuntu repositories provides a sampling of Grub 2 splashimages suitable for background use. The package is grub2-splashimages. Once installed, the images are stored in /usr/share/images/grub

    Note: If the image name includes spaces, the image is copied to a (hidden) file named .background_cache.* and an "unexpected operator" message is generated while running 'update-grub'. The image will still appear during boot, with Grub2 using the file /boot/grub/.background_cache.*. Thanks to forum member Anduu for posting this behavior.

    Besides the simplicity of activating a background, Grub 2 now should auto-detect video capabilities and provide what it considers the best resolution. It will stretch any image to fill the screen. It's pretty easy to add a bit of eye candy.

    Procedure:
    1. Copy any image (jpg, png or tga) to the /boot/grub folder.
    2. Run "sudo update-grub".
    3. Done. How easy was that?


    Additional Info:

    Image Priority:
    1. GRUB_BACKGROUND=</path/filename> setting in /etc/default/grub
      • Available in updated versions of Grub 1.98
      • Example: GRUB_BACKGROUND=/boot/grub/myimages/eyecandy.png
    2. First image found in /boot/grub
      • The first image found, in this order: jpg, JPG, jpeg, JPEG, png, PNG, tga, TGA
      • If multiple images of the same extension, alphanumerically.
    3. Wallpaper designated in /usr/share/desktop-base/grub_backgorund.sh (if desktop-base installed)
    4. /usr/share/images/desktop-base/desktop-grub.png (if desktop-base is installed)
    5. Default theme (no image): Aubergine background, selected item black on light gray background)


    Gotchas
    • Don't forget to run "sudo update-grub"
    • If you have multiple distros on your system, remember the change must be made to the controlling Grub
    • Grub 1.99 RC or later.
    • Images should be RGB, i.e. non-indexed (in GIMP, Image > Mode) and jpeg images should be 8-bit.


    When the user specifies a custom background, the Grub developers decided to be conservative and specified a black/white font scheme. They were kind enough to include a comment about it in /etc/grub.d/05_debian_theme but left it to the user to figure out how to deal with the font colors when using custom backgrounds. Font color selection is discussed in the next section.


    Font Colors & Backgrounds

    First, keep in mind that Grub 2 considers black used as the second color entry as transparent. You will see the background image wherever black is the second entry (e.g. green/black = green text on transparent background).

    • color1/color2

      Two colors must be designated when assigning colors, separated by a /
      I'll call them color1 and color2 in this guide.

      According to the GNU GRUB manual, the colors can be designated as HTML-style (#000000), comma-separated RGB (128,255,255), and SVG 1.0 lowercase color names (midnightblue). To date, I have had success using the following designations:
      black blue brown cyan dark-gray green light-cyan light-blue light-green light-gray light-magenta light-red magenta red white yellow

      • color1 is the text color

      • color2 is the background color or transparency (black)
        • color2 must be 'black' for a background image to be visible.
        • 'black' as color2 is regarded as transparent.
        • Any other color will hide all or part of any background image being used.


    • Menu Settings

      There are two conditions (normal & highlight) and two locations (menu or unspecified) possible within the Grub menu:


      • Conditions


        • Highlighted or selected text
          • The selected line is highlighted fully across the entire line, producing a 'bar'.
          • color1 determines the font color. color2 determines the bar color.

        • Non-highlighted or unselected text.
          • color1 determines the font color. color2 determines the background color or transparency of all non-highlighted areas.


      • Locations


        • menu_color_ : The area within the menu border.
        • color_ : The area outside the menu borders. It will also control items within the menu border if menu_color_ is not specified.



      The following are the entries which will be added to /etc/grub.d/05_debian_theme in the next section.


      • Selected Entry within the Grub Menu Border (one line) is controlled by:
        • Code:
          menu_color_highlight=color1/color2
        • Colors of selected text & background within the Grub2 menu border.
        • Defaults to color_highlight settings if not specified.


      • Non-selected entries within the Grub Menu Border (the rest) are controlled by:
        • Code:
          menu_color_normal=color1/color2
        • Colors of non-selected text & background within the Grub2 menu border.
        • Defaults to color_normal settings if not specified.


      • Highlighted Text Outside the Grub Border (one line) is controlled by:
        • Code:
          color_highlight=color1/color2
        • If there is no menu_color_highlight entry this setting is used within the Grub2 menu border for the selected entry line.


      • Text/Colors Outside the Grub Border are controlled by:
        • Code:
          color_normal=color1/color2
        • Colors of text & background outside the Grub2 menu border.
        • If there is no menu_color_normal entry this setting is used within the Grub2 menu border for the non-selected areas.


      An Example
      menu.png

      The background image was a black screen with an Ubuntu logo. The image is visible within the menu border since both "menu_color..." entries have black as the second color. The image is not visible outside the menu box since the "color_normal" color2 is not 'black' (transparent).

      menu_color_normal=white/black
      menu_color_highlight=yellow/black
      color_normal=green/red
      color_highlight=black/white (Not illustrated)



    Editing Font Colors
    • As root, open /etc/grub.d/05_debian_theme for editing. The sections to be edited is currently at approximately line 98 (line 105 in Grub 1.99):
      Code:
      gksu gedit +98 /etc/grub.d/05_debian_theme
      • Add lines 2 & 3, using the colors you desire, in two places.
        echo "if background_image `make_system_path_relative_to_its_root "${1}"`; then"
        echo " set color_normal=light-gray/black"
        echo " set color_highlight=green/black"

        if [ -n "${2}" ]; then
        if [ -z "${2}" ] && [ -z "${3}" ]; then
        echo " set color_normal=light-gray/black"
        echo " set color_highlight=green/black"

        echo " true"
        fi
    • Save the file, then update Grub.
      Code:
      sudo update-grub


    Real-Time Testing Graphics & Font Colors at the Grub2 menu

    Font & background changes take effect immediately when editing the Grub 2 menu from the grub prompt, so immediate feedback while testing color combinations is possible.


    1. At the Grub2 menu (hold SHIFT during boot if it doesn't display. But hey, if it doesn't display why are you wasting time with a grub background ).

    2. Press 'c' to get the grub prompt.


      • Change the background image:
      • Code:
        background_image <path/filename>
        • Example: background_image /boot/grub/natty.png # Assumes prefix is set to (hdX,Y)/boot/grub


      • Change the font & background colors:
      • Code:
        set <selection>=color1/color2
        • Example: set menu_color_highlight=yellow/blue


    3. To see all current settings type set at the grub prompt.

    4. Changes to color_normal are seen immediately at the grub prompt. To see the menu changes press ESC to return to the Grub2 menu.



    Don't forget

    • You are just testing the settings at the Grub prompt/menu. Once you have settled on your color combinations, boot, make the changes to /etc/grub.d/05_debian_theme, save the file.
    • update-grub for the changes to be incorporated in grub.cfg.


    This guide is a compilation of several threads/posts originally in the Natty Testing Forum.


    Other Grub 1.99 Links:
    Grub 1.99 Changes
    Grub 1.99 Submenus
    Last edited by drs305; July 4th, 2012 at 12:08 AM. Reason: Migrated to help.ubuntu.com/community
    Back to Xorg...

    Retired.

  2. #2
    Join Date
    Jul 2006
    Location
    Castrum, Germania Secunda
    Beans
    1,071

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Well, it appears that the devs have succeeded in making this operation both easier and more difficult at the same time. Without communicating the change to us common users, as usual.

    Firstly, thanks for this guide.
    Secondly: how can I add a colour change of the menu font, to 05_debian_theme? In other words, how can I specify color1/color2? Which code lines do I add, and where do I add them?

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Quote Originally Posted by Pjotr123 View Post
    Firstly, thanks for this guide.
    Secondly: how can I add a colour change of the menu font, to 05_debian_theme? In other words, how can I specify color1/color2? Which code lines do I add, and where do I add them?
    First. you are welcome.

    Secondly, I just about jumped when I started looking in the first post. It's there, but even the author (that would be me ) had to look twice. I'll make the text stand out, but the operative line is (emphasis added):

    The following are the entries which will be added to /etc/grub.d/05_debian_theme in the next section.
    Here is a link that explains some of the major changes for Grub 1.99, and it includes a link to the developer's message detailing all the changes. I've only highlighted the major ones noticeable by a normal user; many of the changes expand the filesystems with which Grub 1.99 will work and do things behind the scene.
    Grub 1.99 Changes
    Last edited by drs305; May 21st, 2011 at 05:16 AM.
    Back to Xorg...

    Retired.

  4. #4
    Join Date
    Jul 2006
    Location
    Castrum, Germania Secunda
    Beans
    1,071

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Thanks a lot! That worked just fine (see the attached picture).

    A tip: if you would add to your excellent guide that the font colour entries have to be applied in "# Step #7" in 05_debian_theme, somewhere in the middle of that text file, then this would make it even easier.

    Enjoy your Saturday (beautiful sunny day over here in Noord-Brabant, I'm off on my bicycle in half an hour, to make a trip through the woods).

    Regards, Pjotr.
    Attached Images Attached Images

  5. #5
    Join Date
    Jan 2009
    Beans
    9

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Good morning!

    Just getting into an old thread.

    I am having a slight problem with my changes to the Grub menu. I have tried putting my background image directly into the /boot/grub folder, or as a GRUB_BACKGROUND=</path/filename> setting in /etc/default/grub (not at the same time). Both ways work perfectly. The problem comes when I try to modify the menu colours in the 05_debian_theme folder. My modified colours are not used and I am left with the default ones. If I remove the background image then my modified colours are used. Is there something else I should do?

    Dave

  6. #6
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Thumbs up Re: Grub 2 Drop-In Backgrounds & Font Selection

    Quote Originally Posted by dmalloch View Post
    I am having a slight problem with my changes to the Grub menu. I have tried putting my background image directly into the /boot/grub folder, or as a GRUB_BACKGROUND=</path/filename> setting in /etc/default/grub (not at the same time). Both ways work perfectly. The problem comes when I try to modify the menu colours in the 05_debian_theme folder. My modified colours are not used and I am left with the default ones. If I remove the background image then my modified colours are used. Is there something else I should do?

    Dave
    You are probably having the problem because the grub menu is using a different part of a conditional statement when it finds an image. If you look at /boot/grub/grub.cfg, there is a section that initially might look like
    Code:
    if background_image /boot/grub/drs.png; then
      true
    else
      set menu_color_normal=white/black
      set menu_color_highlight=black/light-gray
    If that is what your file looks like, you have to edit 05_debian_theme to include some instructions within the "if background_image" section and before the else section.

    Take a look at the "Editing font colors" in the first post to see the extra lines which must be added to 05....
    Last edited by drs305; July 27th, 2011 at 07:55 PM.
    Back to Xorg...

    Retired.

  7. #7
    Join Date
    Jan 2009
    Beans
    9

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Thanks very much, that did the trick. I should have paid closer attention to your excellent explanation.

  8. #8
    Join Date
    Apr 2011
    Location
    Beirut, Lebanon
    Beans
    8
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Not working...

    I put an image in /boot/grub/ and ran update-grub. When I restarted, the background was black instead of the usual aubergine.

    When I enter into console mode in grub and try to set the image using the [ background_image <path/filename> ] method it gives me "Error: Unsupported Bitmap Format."

    Wasn't this supposed to be simple?

    Shadi

  9. #9
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    Quote Originally Posted by Chakoo View Post
    Not working...

    I put an image in /boot/grub/ and ran update-grub. When I restarted, the background was black instead of the usual aubergine.

    When I enter into console mode in grub and try to set the image using the [ background_image <path/filename> ] method it gives me "Error: Unsupported Bitmap Format."

    Wasn't this supposed to be simple?

    Shadi
    Looking at the Grub 1.99 manual,bitmap images are not supported for background images. Use a jpg, tga or png image.

    Attached is a PNG file which works.
    Attached Images Attached Images
    Last edited by drs305; October 29th, 2011 at 01:48 PM.
    Back to Xorg...

    Retired.

  10. #10
    Join Date
    Apr 2011
    Location
    Beirut, Lebanon
    Beans
    8
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Grub 2 Drop-In Backgrounds & Font Selection

    I didn't even use a bitmap image... I was trying a JPG image that I made myself, and then I tried one from the grub2-splashimages and still didn't work.

    Plus when I removed them all and ran update-grub, the background was still black not the ubuntu purple.
    Last edited by Chakoo; October 29th, 2011 at 04:44 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •