Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adjust-grub-theme/adjust_grub_theme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (s *su) TestAdjustThemeNormal() {
defer func() {
_ = os.RemoveAll(optThemeOutputDir)
}()
err = adjustThemeNormal()
err = adjustThemeNormalV20()
assert.Equal(s.T(), nil, err)

}
Expand Down
108 changes: 106 additions & 2 deletions adjust-grub-theme/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ func adjustTheme() {
if optFallbackOnly {
return
}
err = adjustThemeNormal()
err = adjustThemeNormalV25()
if err != nil {
logger.Fatal(err)
}
}

func adjustThemeNormal() error {
func adjustThemeNormalV20() error {
themeInputDir := filepath.Join(optThemeInputDir, themeNameNormal)
themeOutputDir := filepath.Join(optThemeOutputDir, themeNameNormal)

Expand Down Expand Up @@ -409,6 +409,100 @@ func adjustThemeNormal() error {
return err
}

func adjustThemeNormalV25() error {
themeInputDir := filepath.Join(optThemeInputDir, themeNameNormal)
themeOutputDir := filepath.Join(optThemeOutputDir, themeNameNormal)

cleanupThemeOutputDir(themeOutputDir)
err := os.MkdirAll(themeOutputDir, 0755)
if err != nil {
return err
}
copyThemeFiles(themeInputDir, themeOutputDir)

bgImg, themeBgImg, err := loadV25BackgroundImage()
if err != nil {
return err
}

err = saveJpeg(bgImg, filepath.Join(themeOutputDir, "background.jpg"))
if err != nil {
return err
}
if themeBgImg != nil {
err = saveJpeg(themeBgImg, filepath.Join(themeOutputDir, "background_in_theme.jpg"))
if err != nil {
return err
}
} else {
_, err = copyFile(filepath.Join(themeOutputDir, "background.jpg"),
filepath.Join(themeOutputDir, "background_in_theme.jpg"))
if err != nil {
return err
}
}

themeFile := filepath.Join(themeInputDir, "theme.txt.tpl")
theme, err := tt.ParseThemeFile(themeFile)
if err != nil {
return err
}

bootMenu := theme.FindComponentByType(tt.ComponentTypeBootMenu)
if bootMenu != nil {
adjustBootMenuV25(bootMenu, optScreenWidth, optScreenHeight)
}

for _, comp := range theme.Components {
if comp.Type == tt.ComponentTypeLabel {
adjustLabelText(comp)
}
}

themeOutput := filepath.Join(themeOutputDir, "theme.txt")
themeOutputFh, err := os.Create(themeOutput)
if err != nil {
return err
}
defer func() {
_ = themeOutputFh.Close()
}()
bw := bufio.NewWriter(themeOutputFh)
// write head
_, err = fmt.Fprintf(bw, "#version:%d\n", VERSION)
if err != nil {
return err
}
_, err = fmt.Fprintf(bw, "#lang:%s\n", optLang)
if err != nil {
return err
}

var inputDir string
inputDir, err = filepath.Abs(themeInputDir)
if err != nil {
logger.Warning(err)
inputDir = themeInputDir
}

_, err = fmt.Fprintf(bw, "#themeInputDir:%s\n", inputDir)
if err != nil {
return err
}

_, err = fmt.Fprintln(bw, "#head end")
if err != nil {
return err
}

_, err = theme.WriteTo(bw)
if err != nil {
return err
}
err = bw.Flush()
return err
}

func adjustThemeFallback() error {
themeInputDir := filepath.Join(optThemeInputDir, themeNameFallback)
themeOutputDir := filepath.Join(optThemeOutputDir, themeNameFallback)
Expand Down Expand Up @@ -984,6 +1078,16 @@ func adjustBootMenu(themeOutputDir string, comp *tt.Component, vars map[string]f
adjustScrollbarThumbPixmapStyle(scrollbarThumbR)
}

func adjustBootMenuV25(comp *tt.Component, width, height int) {
if width == 1024 && height == 768 {
// halfWidthPercent represents half of the boot menu width percentage.
// The boot menu is centered, so width = halfWidthPercent * 2, left = 50% - halfWidthPercent,
const halfWidthPercent = 18
comp.SetProp("width", tt.RelNum(halfWidthPercent*2))
comp.SetProp("left", tt.RelNum(50-halfWidthPercent))
}
}

const (
orientationHorizontal = 0
orientationVertical = 1
Expand Down
10 changes: 10 additions & 0 deletions grub_theme/themetxt/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ func (t *Theme) Dump() {
}
}

// FindComponentByType finds the first component by component type
func (t *Theme) FindComponentByType(compType string) *Component {
for _, comp := range t.Components {
if comp.Type == compType {
return comp
}
}
return nil
}

func (t *Theme) WriteTo(w io.Writer) (n int64, err error) {
for _, prop := range t.Props {
var pn int
Expand Down
Binary file added misc/data/grub-themes/deepin-v20/terminal_box_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions misc/data/grub-themes/deepin-v20/theme.txt.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Global properties
title-text: ""
desktop-image: "background.jpg"
desktop-color: "#000000"
terminal-font: "Unifont:style=Medium;1"
terminal-box: "terminal_box_*.png"
terminal-left: "0"
terminal-top: "0"
terminal-width: "100%"
terminal-height: "100%"
terminal-border: "0"

# Boot menu
+ boot_menu {
left = "(screen_width - width) / 2"
top = "(screen_height - height) / 2"
width = "1.7 * height"
height = "6*item_spacing + 8*item_height + 2*item_r + 3"
item_font = "Noto Sans CJK SC :style=Regular;1"
item_color = "#dddddd"
selected_item_color = "#ffffff"
item_height = "font_height * 1.574"
item_spacing = "font_height * 0.328"
item_padding = "font_height * 0.328"
icon_width = "font_height * 1.115"
icon_height = "font_height * 0.787"
item_icon_space = "font_height * 0.656"
item_pixmap_style = "item_*.png"
selected_item_pixmap_style = "selected_item_*.png"
menu_pixmap_style = "menu_*.png"
scrollbar_thumb = "scrollbar_thumb_*.png"
}

# Countdown message
+ label {
_id = "label1"
left = 0
top = "screen_height - 1 * font_height"
width = 100%
align = "center"
id = "__timeout__"
# DE
# text = "Start in %d Sekunden."
# EN
_text_en = "Booting in %d seconds"
# ES
# text = "Arranque en% d segundos"
# FR
# text = "Démarrage automatique dans %d secondes"
# NO
# text = "Starter om %d sekunder"
# PT
# text = "Arranque automático dentro de %d segundos"
# RU
# text = "Загрузка выбранного пункта через %d сек."
# UA
# text = "Автоматичне завантаження розпочнеться через %d сек."
# zh_CN
_text_zh_CN = "在 %d 秒内启动"
# zh_TW
_text_zh_TW = "在 %d 秒內啟動"
# zh_HK
_text_zh_HK = "在 %d 秒內啟動"
color = "#99E53E"
font = "Noto Sans CJK SC :style=Regular;0.85"
}

# Navigation keys hint
+ label {
_id = "label2"
left = 0
top = "screen_height - 2 * font_height"
width = 100%
align = "center"
# DE
# text = "System mit ↑ und ↓ auswählen und mit Enter bestätigen."
# EN
_text_en = "Use ↑ and ↓ keys to change selection, Enter to confirm, E to edit the commands before booting or C for a command-line"
# ES
# text = "Use las teclas ↑ y ↓ para cambiar la selección, Enter para confirmar"
# FR
# text = "Choisissez le système avec les flèches du clavier (↑ et ↓), puis validez avec la touche Enter (↲)"
# NO
# text = "Bruk ↑ og ↓ for å endre menyvalg, velg med Enter"
# PT
# text = "Use as teclas ↑ e ↓ para mudar a seleção, e ENTER para confirmar"
# RU
# text = "Используйте клавиши ↑ и ↓ для изменения выбора, Enter для подтверждения"
# UA
# text = "Використовуйте ↑ та ↓ для вибору, Enter для підтвердження"
# zh_CN
_text_zh_CN = "使用 ↑ 和 ↓ 键移动选择条,Enter 键确认,E 键编辑启动命令,C 键进入命令行"
# zh_TW
_text_zh_TW = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
# zh_HK
_text_zh_HK = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
color = "#99E53E"
font = "Noto Sans CJK SC :style=Regular;0.85"
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/data/grub-themes/deepin/selected_item_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/data/grub-themes/deepin/selected_item_e.png
Binary file added misc/data/grub-themes/deepin/selected_item_n.png
Binary file added misc/data/grub-themes/deepin/selected_item_ne.png
Binary file added misc/data/grub-themes/deepin/selected_item_nw.png
Binary file added misc/data/grub-themes/deepin/selected_item_s.png
Binary file added misc/data/grub-themes/deepin/selected_item_se.png
Binary file added misc/data/grub-themes/deepin/selected_item_sw.png
Binary file added misc/data/grub-themes/deepin/selected_item_w.png
Binary file modified misc/data/grub-themes/deepin/terminal_box_c.png
Binary file added misc/data/grub-themes/deepin/terminal_box_e.png
Binary file added misc/data/grub-themes/deepin/terminal_box_n.png
Binary file added misc/data/grub-themes/deepin/terminal_box_ne.png
Binary file added misc/data/grub-themes/deepin/terminal_box_nw.png
Binary file added misc/data/grub-themes/deepin/terminal_box_s.png
Binary file added misc/data/grub-themes/deepin/terminal_box_se.png
Binary file added misc/data/grub-themes/deepin/terminal_box_sw.png
Binary file added misc/data/grub-themes/deepin/terminal_box_w.png
110 changes: 36 additions & 74 deletions misc/data/grub-themes/deepin/theme.txt.tpl
Original file line number Diff line number Diff line change
@@ -1,100 +1,62 @@
# Global properties
# GRUB2 gfxmenu Linux Deepin theme
# Designed for any resolution

# Global Property
title-text: ""
desktop-image: "background.jpg"
desktop-image: "background_in_theme.jpg"
desktop-color: "#000000"
terminal-font: "Unifont:style=Medium;1"
terminal-font: "Unifont Regular 14"
terminal-box: "terminal_box_*.png"
terminal-left: "0"
terminal-top: "0"
terminal-width: "100%"
terminal-height: "100%"
terminal-border: "0"

# Boot menu
# Show the boot menu
+ boot_menu {
left = "(screen_width - width) / 2"
top = "(screen_height - height) / 2"
width = "1.7 * height"
height = "6*item_spacing + 8*item_height + 2*item_r + 3"
item_font = "Noto Sans CJK SC :style=Regular;1"
left = 34%
top = 51%
width = 32%
height = 50%
item_font = "Unifont Regular 16"
item_color = "#dddddd"
selected_item_color = "#ffffff"
item_height = "font_height * 1.574"
item_spacing = "font_height * 0.328"
item_padding = "font_height * 0.328"
icon_width = "font_height * 1.115"
icon_height = "font_height * 0.787"
item_icon_space = "font_height * 0.656"
item_pixmap_style = "item_*.png"
item_height = 18
item_spacing = 25
selected_item_pixmap_style = "selected_item_*.png"
menu_pixmap_style = "menu_*.png"
scrollbar_thumb = "scrollbar_thumb_*.png"
}

# Countdown message
# Show a countdown message using the label component
+ label {
_id = "label1"
left = 0
top = "screen_height - 1 * font_height"
width = 100%
align = "center"
id = "__timeout__"
# DE
# text = "Start in %d Sekunden."
# EN
left = 0
top = 97%
width = 100%
align = "center"
id = "__timeout__"
_text_en = "Booting in %d seconds"
# ES
# text = "Arranque en% d segundos"
# FR
# text = "Démarrage automatique dans %d secondes"
# NO
# text = "Starter om %d sekunder"
# PT
# text = "Arranque automático dentro de %d segundos"
# RU
# text = "Загрузка выбранного пункта через %d сек."
# UA
# text = "Автоматичне завантаження розпочнеться через %d сек."
# zh_CN
_text_zh_CN = "在 %d 秒内启动"
# zh_TW
_text_zh_TW = "在 %d 秒內啟動"
# zh_HK
_text_zh_HK = "在 %d 秒內啟動"
color = "#99E53E"
font = "Noto Sans CJK SC :style=Regular;0.85"
color = "#7d7d7d"
font = "Unifont Regular 16"
}

# Navigation keys hint
+ label {
_id = "label2"
left = 0
top = "screen_height - 2 * font_height"
width = 100%
align = "center"
# DE
# text = "System mit ↑ und ↓ auswählen und mit Enter bestätigen."
# EN
_text_en = "Use ↑ and ↓ keys to change selection, Enter to confirm, E to edit the commands before booting or C for a command-line"
# ES
# text = "Use las teclas ↑ y ↓ para cambiar la selección, Enter para confirmar"
# FR
# text = "Choisissez le système avec les flèches du clavier (↑ et ↓), puis validez avec la touche Enter (↲)"
# NO
# text = "Bruk ↑ og ↓ for å endre menyvalg, velg med Enter"
# PT
# text = "Use as teclas ↑ e ↓ para mudar a seleção, e ENTER para confirmar"
# RU
# text = "Используйте клавиши ↑ и ↓ для изменения выбора, Enter для подтверждения"
# UA
# text = "Використовуйте ↑ та ↓ для вибору, Enter для підтвердження"
# zh_CN
_text_zh_CN = "使用 ↑ 和 ↓ 键移动选择条,Enter 键确认,E 键编辑启动命令,C 键进入命令行"
# zh_TW
_text_zh_TW = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
# zh_HK
_text_zh_HK = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
color = "#99E53E"
font = "Noto Sans CJK SC :style=Regular;0.85"
left = 0
top = 94%
width = 100%
align = "center"
color = "#7d7d7d"
font = "Unifont Regular 16"
# EN
_text_en = "Use ↑ and ↓ keys to change selection, Enter to confirm, E to edit the commands before booting or C for a command-line"
# zh_CN
_text_zh_CN = "使用 ↑ 和 ↓ 键移动选择条,Enter 键确认,E 键编辑启动命令,C 键进入命令行"
# zh_TW
_text_zh_TW = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
# zh_HK
_text_zh_HK = "使用 ↑ 和 ↓ 鍵移動選擇條,Enter 鍵確認,E 鍵編輯啟動命令,C 鍵進入命令行"
}

Binary file not shown.
Binary file added misc/data/grub-themes/deepin/uos_background.jpg
Loading