【Grub2】Grub2主題美化
資料連結:
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 = "@
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 = "@
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 = "@[email protected]"
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 = "@[email protected]"
#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 = "@[email protected]"
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" }
}