【Grub2】Grub2主题美化

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xinlan3618/article/details/78963513

Grub主题美化其实很简单,结构性很强,比较有条理,逐步设置就能做出满意的theme。

资料链接:

https://www.gnu.org/software/grub/manual/grub/grub.html#Theme-Elements

http://wiki.rosalab.ru/en/index.php/Grub2_theme_/_reference#Boot_menu_.28boot_menu.29


grub主题由以下部分组成,Global option(全局选项),Boot menu(启动菜单),progress bar(进度条),circular progress(环形进度条),label (标签),image(图形)、vertical box(垂直框架),horizontal box(水平框架),canvas(画布)。其中Vbox、Hbox、Canvas为容器组件,可以在内部排布其他组件,如image、label、boot menu。


全局选项包含的设置:
Title包含以下设置内容,title的align属性为center,且top属性为10%,此两项为默认的属性,不可进行设置更改。
title-text: "Title-Grub2.02"
title-font: "DejaVu_bold_14.pf2"
title-color: "#EEAD0E"
message包含以下设置内容
message-font: "dejavu_16.pf2"
message-color: "#FFF0F5"
message-bg-color: "#696969"
desktop包含以下设置内容,若image属性指定图片,且图片存在,则color属性不生效。
desktop-image: "background.png"
desktop-image-scale-method: "fitwidth"
desktop-image-h-align: "center"
desktop-image-v-align: "center"
desktop-color: "#B5B5B5"
terminal 包含以下设置内容,其中box为,style box对象,通过正则表达式查找对应方位的图片,先定位四角,四边和中间进行拉伸填充。文本的显示位置为w、e、s、n,四个边框组成的center内部区域,四个边框区域不能显示文本内容。只有当terminal-box未指定时,border属性才生效。
terminal-box: "terminal_*.png"
terminal-font: "dejavu_10.pf2"
terminal-top : "0"
terminal-left : "0"
terminal-width : "300"
terminal-height : "200"
terminal-border : "10"


boot menu设置:
第一部分为位置和尺寸属性,位置参数(top和left)是以所在容器的坐标为原点,若将boot menu放于canvas容器内,将以canvas的top和left为原点。
top = 200
left = 300
width = 200
height = 150
第二部分为menu指定style box,此部分可指定一部分,不需要凑齐所有9块图片,为指定的方位图片,可能会留空或通过拉伸进行填充。
menu_pixmap_style = "menu_*.png"
第三部分,指定菜单项的属性,
item_font = "dejavu_14"
item_color = "#EE2C2C"
max_items_shown = 2-控制显示的数量,此项实验时不起作用。


item_height = 25-启动项的高度,此项将影响item_pixmap_style的高度。
item_padding = 10-此项的距离为所有菜单项组成的区域外围,与center边界的距离,为四周距离。
item_spacing = 5-item项与项之间的距离
item_pixmap_style = "item_*.png"-item项未选中时显示的style box


icon_height = 20-通过—class属性指定的png图形的高度,
icon_width = 20-通过—class属性指定的png图形的宽度
item_icon_space = 10-icon和menu entry的title之间的距离




selected_item_font = "dejavu_bold_14"-选中项的字体
selected_item_color= "#C0FF3E"-选中项的文字颜色
selected_item_pixmap_style = "select_hl_*.png"-选中项的style box


scrollbar = true -启动项过多时,滚动条启用
scrollbar_width = 19
scrollbar_height = 37
scrollbar_thumb = "slider_*.png"-滚动条的图形
#scrollbarf_thumb_overlay = "false"
#scrollbar_slice = "east"
#scrollbar_left_pad = "west"
#scrollbar_right_pad = "east"
#scrollbar_top_pad = pixels
#scrollbar_bottom_pad = pixels


#visible = "false"-菜单是否可见


progress bar设置内容
id = "__timeout__"


top = 400
left = 100
height = 15
width = 300


#fg_color = "#fff"-若不指定bar_style和highlight style将启用此项
#bg_color = "#6ac"
#border_color = "#fff"


font = "dejavu_10"
text_color = "#000"
text = "@TIMEOUT_NOTIFICATION_LONG@"


bar_style = "progress_bar_*.png"
highlight_style = "progress_mark_*.png"
highlight_overlay = "false"




circular_progress设置内容{
id = "__timeout__"


top = 50
left = 50
height = 100
width = 100


center_bitmap = "tick_center.png"
tick_bitmap = "tick_mark.png"-类似于表针,将会围着center_bitmap旋转,但是图片的方向不进行旋转,所以最好用圆形的tick_bitmap.
num_ticks = 30-显示多少次tick_bitmap
start_angle = "36 deg"-开始的角度


ticks_disappear  = "true"-转过的角度是否消失,true为不消失。


Lable的设置内容
top = 300
left = 50%-200
width = 400
height = 20


text = "@KEYMAP_MIDDLE@"
font = "dejavu_12"
color = "#76EE00"
align = "center"


visible = "true"


image 的设置内容
top = 50
left = 200
width = 100
height = 100
file = "image.png"


canvas 的设置内容,只需要指定位置和尺寸
top = 50
left = 350
width = 100
height = 100


hbox和vbox的设置内容,只需要指定位置,无width和height属性,hbox采用内部组件的高度,vbox采用内部组件的宽度。
top = 50
left = 350

示意图及示意代码


# Default theme for GRUB2
#
# Copyright (C) 2011 Daniel Tschudi
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


#定义title的文本,字体,颜色
#title settings
title-text: "Title-Grub2.02"
title-font: "DejaVu_bold_14.pf2"
title-color: "#EEAD0E"


#定义message的的字体、颜色、背景颜色
#general settings
message-font: "dejavu_16.pf2"
message-color: "#FFF0F5"
message-bg-color: "#696969"


#desktop的背景图片,图片的缩放方式,水平、垂直对齐方式,背景颜色(若指定图片,且图片存在,此项不生效)
#desktop setting
desktop-image: "background.png"
desktop-image-scale-method: "fitwidth"
desktop-image-h-align: "center"
desktop-image-v-align: "center"
desktop-color: "#B5B5B5"


#terminal终端的边框,内部的字体,border
#terminal setting
terminal-box: "terminal_*.png"
terminal-font: "dejavu_10.pf2"
terminal-top : "0"
terminal-left : "0"
terminal-width : "300"
terminal-height : "200"
#当box未指定,或文件不存在时,才会执行此部分命令。
terminal-border : "10"




#菜单项
#boot menu
+ boot_menu {


top = 200
left = 300
width = 200
height = 150
menu_pixmap_style = "menu_*.png"


item_font = "dejavu_14"
item_color = "#EE2C2C"
max_items_shown = 2

item_height = 25
item_padding = 10
item_spacing = 5
#设置自带显示的style box,在此为空
item_pixmap_style = "item_*.png"




icon_height = 20
icon_width = 20
item_icon_space = 10



selected_item_font = "dejavu_bold_14"
selected_item_color= "#C0FF3E"
#设置选中项style box
selected_item_pixmap_style = "select_hl_*.png"

scrollbar = true
scrollbar_width = 19
scrollbar_height = 37
scrollbar_thumb = "slider_*.png"
#scrollbarf_thumb_overlay = "false"
#scrollbar_slice = "east"
#scrollbar_left_pad = "west"
#scrollbar_right_pad = "east"
#scrollbar_top_pad = pixels
#scrollbar_bottom_pad = pixels

#visible = "false"




}


#progress bar
+ progress_bar {
id = "__timeout__"

#fg_color = "#fff"
#bg_color = "#6ac"
#border_color = "#fff"

top = 400
left = 100
height = 15
width = 300

font = "dejavu_10"
text_color = "#000"
text = "@TIMEOUT_NOTIFICATION_LONG@"

bar_style = "progress_bar_*.png"
highlight_style = "progress_mark_*.png"
highlight_overlay = "false"
}


#progress bar
+ progress_bar {
id = "__timeout__"

fg_color = "#fff"
bg_color = "#6ac"
border_color = "#fff"

top = 450
left = 100
height = 15
width = 300

font = "dejavu_10"
text_color = "#000"
text = "@TIMEOUT_NOTIFICATION_LONG@"

#bar_style = "progress_bar_*.png"
#highlight_style = "progress_mark_*.png"
#highlight_overlay = "false"
}


+ circular_progress {
id = "__timeout__"


top = 50
left = 50
height = 100
width = 100

center_bitmap = "tick_center.png"
tick_bitmap = "tick_mark.png"
num_ticks = 30
start_angle = "36 deg"

ticks_disappear  = "true"


}


#help bar at the bottom
+ label {
top = 300
left = 50%-200
width = 400
height = 20

text = "@KEYMAP_MIDDLE@"

font = "dejavu_12"
color = "#76EE00"
align = "center"

visible = "true"
}


# image setting
+ image {
    top = 50
    left = 200
    width = 100
    height = 100
    file = "image.png"
}


+canvas {
top = 50
left = 350
width = 100
height = 100

+ image {
top = 25
left = 25
width = 50
height = 50
file = "image.png"
}



}


+ hbox {
    top = 400
    left = 50


    + label { text = "up & down" font = "dejavu_14" color = "#87a556" }
    + label { 
text = ":select       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "enter" font = "dejavu_14" color = "#87a556" }
    + label { text = ":boot       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "e" font = "dejavu_14" color = "#87a556" }
    + label { text = ":edit       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "c" font = "dejavu_14" color = "#87a556" }
    + label { text = ":command-line       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "esc" font = "dejavu_14" color = "#87a556" }
    + label { text = ":retour menu" font = "dejavu_14" color = "gainsboro" }
}


+ vbox {
    top = 50
    left = 500



    + label { text = "123456789" font = "dejavu_14" color = "#87a556" }
    + label { text = ":abcdefg" font = "dejavu_14" color = "gainsboro" }
    + label { text = "enter" font = "dejavu_14" color = "#87a556" }
    + label { text = ":boot       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "e" font = "dejavu_14" color = "#87a556" }
    + label { text = ":edit       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "c" font = "dejavu_14" color = "#87a556" }
    + label { text = ":command-line       " font = "dejavu_14" color = "gainsboro" }
    + label { text = "esc" font = "dejavu_14" color = "#87a556" }
    + label { text = ":retour menu" font = "dejavu_14" color = "gainsboro" }
}

展开阅读全文

没有更多推荐了,返回首页