Next: Network, Previous: Configuration, Up: Top [Contents][Index]
The GRUB graphical menu supports themes that can customize the layout and appearance of the GRUB boot menu. The theme is configured through a plain text file that specifies the layout of the various GUI components (including the boot menu, timeout progress bar, and text messages) as well as the appearance using colors, fonts, and images. Example is available in docs/example_theme.txt
Colors can be specified in several ways:
The fonts GRUB uses “PFF2 font format” bitmap fonts. Fonts are specified with full font names. Currently there is no provision for a preference list of fonts, or deriving one font from another. Fonts are loaded with the “loadfont” command in GRUB (loadfont). To see the list of loaded fonts, execute the “lsfonts” command (lsfonts). If there are too many fonts to fit on screen, do “set pager=1” before executing “lsfonts”.
Progress bars are used to display the remaining time before GRUB boots the default menu entry. To create a progress bar that will display the remaining time before automatic boot, simply create a “progress_bar” component with the id “__timeout__”. This indicates to GRUB that the progress bar should be updated as time passes, and it should be made invisible if the countdown to automatic boot is interrupted by the user.
Progress bars may optionally have text displayed on them. This text is controlled by variable “text” which contains a printf template with the only argument %d is the number of seconds remaining. Additionally special values “@TIMEOUT_NOTIFICATION_SHORT@”, “@TIMEOUT_NOTIFICATION_MIDDLE@”, “@TIMEOUT_NOTIFICATION_LONG@” are replaced with standard and translated templates.
The circular progress indicator functions similarly to the progress bar. When given an id of “__timeout__”, GRUB updates the circular progress indicator’s value to indicate the time remaining. For the circular progress indicator, there are two images used to render it: the *center* image, and the *tick* image. The center image is rendered in the center of the component, while the tick image is used to render each mark along the circumference of the indicator.
Text labels can be placed on the boot screen. The font, color, and horizontal alignment can be specified for labels. If a label is given the id “__timeout__”, then the “text” property for that label is also updated with a message informing the user of the number of seconds remaining until automatic boot. This is useful in case you want the text displayed somewhere else instead of directly on the progress bar.
The boot menu where GRUB displays the menu entries from the “grub.cfg” file. It is a list of items, where each item has a title and an optional icon. The icon is selected based on the *classes* specified for the menu entry. If there is a PNG file named “myclass.png” in the “grub/themes/icons” directory, it will be displayed for items which have the class *myclass*. The boot menu can be customized in several ways, such as the font and color used for the menu entry title, and by specifying styled boxes for the menu itself and for the selected item highlight.
One of the most important features for customizing the layout is the use of *styled boxes*. A styled box is composed of 9 rectangular (and potentially empty) regions, which are used to seamlessly draw the styled box on screen:
Northwest (nw) | North (n) | Northeast (ne) |
West (w) | Center (c) | East (e) |
Southwest (sw) | South (s) | Southeast (se) |
To support any size of box on screen, the center slice and the slices for the top, bottom, and sides are all scaled to the correct size for the component on screen, using the following rules:
As an example of how an image might be sliced up, consider the styled box used for a terminal view.
The Inkscape_ scalable vector graphics editor is a very useful tool for creating styled box images. One process that works well for slicing a drawing into the necessary image slices is:
The theme file is a plain text file. Lines that begin with “#“ are ignored and considered comments. (Note: This may not be the case if the previous line ended where a value was expected.)
The theme file contains two types of statements:
Global properties are specified with the simple format:
In this example, name3 is assigned a color value.
title-text | Specifies the text to display at the top center of the screen as a title. |
title-font | Defines the font used for the title message at the top of the screen. |
title-color | Defines the color of the title message. |
message-font | Currently unused. Left for backward compatibility. |
message-color | Currently unused. Left for backward compatibility. |
message-bg-color | Currently unused. Left for backward compatibility. |
desktop-image | Specifies the image to use as the background. It will be scaled to fit the screen size or proportionally scaled depending on the scale method. |
desktop-image-scale-method | Specifies the scaling method for the *desktop-image*. Options are “stretch“, “crop“, “padding“, “fitwidth“, “fitheight“. “stretch“ for fitting the screen size. Otherwise it is proportional scaling of a part of *desktop-image* to the part of the screen. “crop“ part of the *desktop-image* will be proportionally scaled to fit the screen sizes. “padding“ the entire *desktop-image* will be contained on the screen. “fitwidth“ for fitting the *desktop-image*’s width with screen width. “fitheight“ for fitting the *desktop-image*’s height with the screen height. Default is “stretch“. |
desktop-image-h-align | Specifies the horizontal alignment of the *desktop-image* if *desktop-image-scale-method* isn’t equeal to “stretch“. Options are “left“, “center“, “right“. Default is “center“. |
desktop-image-v-align | Specifies the vertical alignment of the *desktop-image* if *desktop-image-scale-method* isn’t equeal to “stretch“. Options are “top“, “center“, “bottom“. Default is “center“. |
desktop-color | Specifies the color for the background if *desktop-image* is not specified. |
terminal-box | Specifies the file name pattern for the styled box slices used for the command line terminal window. For example, “terminal-box: terminal_*.png“ will use the images “terminal_c.png“ as the center area, “terminal_n.png“ as the north (top) edge, “terminal_nw.png“ as the northwest (upper left) corner, and so on. If the image for any slice is not found, it will simply be left empty. |
terminal-border | Specifies the border width of the terminal window. |
terminal-left | Specifies the left coordinate of the terminal window. |
terminal-top | Specifies the top coordinate of the terminal window. |
terminal-width | Specifies the width of the terminal window. |
terminal-height | Specifies the height of the terminal window. |
Greater customizability comes is provided by components. A tree of components forms the user interface. *Containers* are components that can contain other components, and there is always a single root component which is an instance of a *canvas* container.
Components are created in the theme file by prefixing the type of component with a ’+’ sign:
+ label { text="GRUB" font="aqui 11" color="#8FF" }
properties of a component are specified as "name = value" (whitespace surrounding tokens is optional and is ignored) where *value* may be:
The following is a list of the components and the properties they support.
Properties:
id | Set to “__timeout__“ to display the time elapsed to an automatical boot of the default entry. |
text | The text to display. If “id“ is set to “__timeout__“ and no “text“ property is set then the amount of seconds will be shown. If set to “@KEYMAP_SHORT@“, “@KEYMAP_MIDDLE@“ or “@KEYMAP_LONG@“ then predefined hotkey information will be shown. |
font | The font to use for text display. |
color | The color of the text. |
align | The horizontal alignment of the text within the component. Options are “left“, “center“ and “right“. |
visible | Set to “false“ to hide the label. |
Properties:
file | The full path to the image file to load. |
Properties:
id | Set to “__timeout__“ to display the time elapsed to an automatical boot of the default entry. |
fg_color | The foreground color for plain solid color rendering. |
bg_color | The background color for plain solid color rendering. |
border_color | The border color for plain solid color rendering. |
text_color | The text color. |
bar_style | The styled box specification for the frame of the progress bar. Example: “progress_frame_*.png“ If the value is equal to “highlight_style“ then no styled boxes will be shown. |
highlight_style | The styled box specification for the highlighted region of the progress bar. This box will be used to paint just the highlighted region of the bar, and will be increased in size as the bar nears completion. Example: “progress_hl_*.png“. If the value is equal to “bar_style“ then no styled boxes will be shown. |
highlight_overlay | If this option is set to “true“ then the highlight box side slices (every slice except the center slice) will overlay the frame box side slices. And the center slice of the highlight box can move all the way (from top to bottom), being drawn on the center slice of the frame box. That way we can make a progress bar with round-shaped edges so there won’t be a free space from the highlight to the frame in top and bottom scrollbar positions. Default is “false“. |
font | The font to use for progress bar. |
text | The text to display on the progress bar. If the progress bar’s ID is set to “__timeout__“ and the value of this property is set to “@TIMEOUT_NOTIFICATION_SHORT@“, “@TIMEOUT_NOTIFICATION_MIDDLE@“ or “@TIMEOUT_NOTIFICATION_LONG@“, then GRUB will update this property with an informative message as the timeout approaches. |
Properties:
id | Set to “__timeout__“ to display the time elapsed to an automatical boot of the default entry. |
center_bitmap | The file name of the image to draw in the center of the component. |
tick_bitmap | The file name of the image to draw for the tick marks. |
num_ticks | The number of ticks that make up a full circle. |
ticks_disappear | Boolean value indicating whether tick marks should progressively appear, or progressively disappear as *value* approaches *end*. Specify “true“ or “false“. Default is “false“. |
start_angle | The position of the first tick mark to appear or disappear. Measured in "parrots", 1 "parrot" = 1 / 256 of the full circle. Use values “xxx deg“ or “xxx \xc2\xb0“ to set the angle in degrees. |
Properties:
item_font | The font to use for the menu item titles. |
selected_item_font | The font to use for the selected menu item, or “inherit“ (the default) to use “item_font“ for the selected menu item as well. |
item_color | The color to use for the menu item titles. |
selected_item_color | The color to use for the selected menu item, or “inherit“ (the default) to use “item_color“ for the selected menu item as well. |
icon_width | The width of menu item icons. Icons are scaled to the specified size. |
icon_height | The height of menu item icons. |
item_height | The height of each menu item in pixels. |
item_padding | The amount of space in pixels to leave on each side of the menu item contents. |
item_icon_space | The space between an item’s icon and the title text, in pixels. |
item_spacing | The amount of space to leave between menu items, in pixels. |
menu_pixmap_style | The image file pattern for the menu frame styled box. Example: “menu_*.png“ (this will use images such as “menu_c.png“, “menu_w.png“, ‘menu_nw.png“, etc.) |
item_pixmap_style | The image file pattern for the item styled box. |
selected_item_pixmap_style | The image file pattern for the selected item highlight styled box. |
scrollbar | Boolean value indicating whether the scroll bar should be drawn if the frame and thumb styled boxes are configured. |
scrollbar_frame | The image file pattern for the entire scroll bar. Example: “scrollbar_*.png“ |
scrollbar_thumb | The image file pattern for the scroll bar thumb (the part of the scroll bar that moves as scrolling occurs). Example: “scrollbar_thumb_*.png“ |
scrollbar_thumb_overlay | If this option is set to “true“ then the scrollbar thumb side slices (every slice except the center slice) will overlay the scrollbar frame side slices. And the center slice of the scrollbar_thumb can move all the way (from top to bottom), being drawn on the center slice of the scrollbar frame. That way we can make a scrollbar with round-shaped edges so there won’t be a free space from the thumb to the frame in top and bottom scrollbar positions. Default is “false“. |
scrollbar_slice | The menu frame styled box’s slice in which the scrollbar will be drawn. Possible values are “west“, “center“, “east“ (default). “west“ - the scrollbar will be drawn in the west slice (right-aligned). “east“ - the scrollbar will be drawn in the east slice (left-aligned). “center“ - the scrollbar will be drawn in the center slice. Note: in case of “center“ slice: a) If the scrollbar should be drawn then boot menu entry’s width is decreased by the scrollbar’s width and the scrollbar is drawn at the right side of the center slice. b) If the scrollbar won’t be drawn then the boot menu entry’s width is the width of the center slice. c) We don’t necessary need the menu pixmap box to display the scrollbar. |
scrollbar_left_pad | The left scrollbar padding in pixels. Unused if “scrollbar_slice“ is “west“. |
scrollbar_right_pad | The right scrollbar padding in pixels. Unused if “scrollbar_slice“ is “east“. |
scrollbar_top_pad | The top scrollbar padding in pixels. |
scrollbar_bottom_pad | The bottom scrollbar padding in pixels. |
visible | Set to “false“ to hide the boot menu. |
The following properties are supported by all components:
The distance from the left border of container to left border of the object in either of three formats:
x | Value in pixels |
p% | Percentage |
p%+x | mixture of both |
The distance from the left border of container to left border of the object in same format.
The width of object in same format.
The height of object in same format.
The identifier for the component. This can be any arbitrary string. The ID can be used by scripts to refer to various components in the GUI component tree. Currently, there is one special ID value that GRUB recognizes:
“__timeout__“ | Component with this ID will be updated by GRUB and will indicate time elapsed to an automatical boot of the default entry. Affected components: “label“, “circular_progress“, “progress_bar“. |
Next: Network, Previous: Configuration, Up: Top [Contents][Index]