Skip to content

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
KZ25T committed Jun 17, 2024
0 parents commit 2d0c991
Show file tree
Hide file tree
Showing 100 changed files with 147 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.deb
debian/boot
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Windows GRUB 样式

仿写了一个类似 Windows Boot Manager 的 GRUB 主题,简体中文版。

## 效果

![1](./img/1.png)

作为对比,这是原版 Windows Boot Manager 在我的电脑中的效果

![2](./img/2.png)

## 使用方法

首先你需要准备好你自己的 `微软雅黑``微软静黑` 字体。文件名一般是 `msyh.ttc``msyhl.ttc``msjh.ttc`,这个可以从 Windows 获得,在 `C:\Windows\Fonts` 里。

### Debian 系简易安装

我提供了 deb 安装包,您需要从 release 里下载 deb 包进行安装,同时根据安装时的终端的提示完成字体配置。

该 deb 包适用于任何架构,但仅限于 Debian 系发行版。卸载该 deb 包时会打扫干净恢复原样。

### 手动安装

对于 Debian 系发行版,手动安装的方法是:

1. 下载本仓库,把本仓库 `src` 目录复制为 `/boot/grub/themes/Windows` 目录。
2. 修改 `/boot/grub/themes/Windows/theme.txt` 第 35 行为你自己的操作系统。
3. 修改 `/etc/grub.d/00_header`,在顶上添加一行

```bash
GRUB_THEME=/boot/grub/themes/Windows/theme.txt
````

4. 修改 `/etc/grub.d/10_linux`,在含有 `gettext_printf "Advanced options for %s"` 的那一行(本人电脑是 393 行)里,`\$menuentry_id_option` 前添加一项 `${CLASS}`(前后带空格)
5. 修改 `/etc/grub.d/30_os-prober`,在含有 `gettext_printf "Advanced options for %s"` 的那一行(本人电脑是 291 行)里,`\$menuentry_id_option` 前添加一项 `${CLASS}`(前后带空格)
6. 修改 `/etc/grub.d/30_uefi-firmware`,在含有 `menuentry '$LABEL'` 的那一行(本人电脑是 37 行)里,`\$menuentry_id_option` 前添加一项 `--class efi`(前后带空格)
7. 完成字体配置

```bash
sudo grub-mkfont -s 24 -o /boot/grub/themes/Windows/msjh24.pf2 your/msjh.ttc
sudo grub-mkfont -s 16 -o /boot/grub/themes/Windows/msyh16.pf2 your/msyh.ttc
sudo grub-mkfont -s 64 -o /boot/grub/themes/Windows/msyh64.pf2 your/msyhl.ttc
```

8. 执行 `update-grub`

其他发行版暂不清楚能否可以运行,但方法类似。

## 感谢

图标来自于 [https://github.com/MrVivekRajan/Grub-Themes](https://github.com/MrVivekRajan/Grub-Themes) 的二次制作。

## 免责声明

本仓库仅供学习交流使用,禁止用于商用,若使用本仓库内容请标明出处。

使用本开源仓库及其成果时,您知道可能对你的计算机产生危害,产生的一切损失由使用者承担。
5 changes: 5 additions & 0 deletions debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: grub-theme-windows
Version: 1.0.0
Architecture: all
Maintainer: github.com/KZ25T
Description: A windows-like GRUB theme
21 changes: 21 additions & 0 deletions debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
cp -r /etc/grub.d /etc/grub.d.bak
source /etc/os-release
echo "generating for $NAME"
sed -i '/^prefix=/i GRUB_THEME=/boot/grub/themes/Windows/theme.txt' /etc/grub.d/00_header
sed -i 's/\(.*Advanced options for %s.*\)\\\$menuentry/\1\${CLASS} \\\$menuentry/' /etc/grub.d/10_linux
sed -i 's/\(.*Advanced options for %s.*\)\\\$menuentry/\1\${CLASS} \\\$menuentry/' /etc/grub.d/30_os-prober
sed -i 's|^\(.*\)\\$menuentry_id_option|\1--class efi \\$menuentry_id_option|' /etc/grub.d/30_uefi-firmware
sed -i "s#HOST_DISTRO#$NAME#g" /boot/grub/themes/Windows/theme.txt
update-grub

echo -e "\e[1;33m"
echo "Attention: This is NOT an ERROR but you have to read it."
echo "We didn't prepare font file because of copyright. YOU SHOULD DO IT YOURSELF LIKE BELOW."
echo "You should prepare your Microsoft YaHei and JhengHei font, name like: msjh.ttc msyh.ttc msyhl.ttc from Windows."
echo "Then run command below:"
echo "\$ sudo grub-mkfont -s 24 -o /boot/grub/themes/Windows/msjh24.pf2 your/msjh.ttc"
echo "\$ sudo grub-mkfont -s 16 -o /boot/grub/themes/Windows/msyh16.pf2 your/msyh.ttc"
echo "\$ sudo grub-mkfont -s 64 -o /boot/grub/themes/Windows/msyh64.pf2 your/msyhl.ttc"
read -s -n 1 -p "DO YOU KNOW THAT? Press RETURN to continue."
echo -e "\e[0m"
16 changes: 16 additions & 0 deletions debian/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
dir_A="/etc/grub.d.bak"
dir_B="/etc/grub.d"

if [ -d "$dir_A" ]; then
if [ -d "$dir_B" ]; then
rm -r "$dir_B"
mv "$dir_A" "$dir_B"
else
echo "We have not found $dir_B, maybe it's wrong, please fix it yourself. Hope you a good luck."
fi
else
echo "Directory $dir_A does not exist, no action taken. Maybe it's wrong, please fix it yourself. Hope you a good luck."
fi

update-grub
Binary file added img/1.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 img/2.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 src/frame_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 src/frame_e.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 src/frame_w.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 src/icons/4MLinux.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 src/icons/AlpineLinux.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 src/icons/Manjaro.i686.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 src/icons/Manjaro.x86_64.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 src/icons/SystemRescueCD.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 src/icons/alma.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 src/icons/android.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 src/icons/anonymous.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 src/icons/antergos.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 src/icons/arch-advance.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 src/icons/arch.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 src/icons/archcraft.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 src/icons/arcolinux.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 src/icons/artix.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 src/icons/bedrock.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 src/icons/cancel.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 src/icons/centos.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 src/icons/chakra.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 src/icons/chromeos.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 src/icons/debian-advance.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 src/icons/debian.png
Binary file added src/icons/deepin.png
Binary file added src/icons/devuan.png
Binary file added src/icons/driver.png
Binary file added src/icons/edit.png
Binary file added src/icons/efi.png
Binary file added src/icons/elementary.png
Binary file added src/icons/endeavouros.png
Binary file added src/icons/fedora.png
Binary file added src/icons/find.efi.png
Binary file added src/icons/find.none.png
Binary file added src/icons/freebsd.png
Binary file added src/icons/garuda.png
Binary file added src/icons/gentoo.png
Binary file added src/icons/gnu-linux.png
Binary file added src/icons/haiku.png
Binary file added src/icons/help.png
Binary file added src/icons/kali.png
Binary file added src/icons/kaos.png
Binary file added src/icons/kbd.png
Binary file added src/icons/korora.png
Binary file added src/icons/kubuntu.png
Binary file added src/icons/lang.png
Binary file added src/icons/lfs.png
Binary file added src/icons/linux.png
Binary file added src/icons/linuxlite.png
Binary file added src/icons/linuxmint.png
Binary file added src/icons/lubuntu.png
Binary file added src/icons/macosx.png
Binary file added src/icons/mageia.png
Binary file added src/icons/manjaro.png
Binary file added src/icons/mate.png
Binary file added src/icons/memtest.png
Binary file added src/icons/mx-linux.png
Binary file added src/icons/neon.png
Binary file added src/icons/nix.png
Binary file added src/icons/nixos.png
Binary file added src/icons/nobara.png
Binary file added src/icons/opensuse.png
Binary file added src/icons/parrot.png
Binary file added src/icons/pop-os.png
Binary file added src/icons/pop.png
Binary file added src/icons/recovery.png
Binary file added src/icons/regolith.png
Binary file added src/icons/restart.png
Binary file added src/icons/rocky.png
Binary file added src/icons/shutdown.png
Binary file added src/icons/siduction.png
Binary file added src/icons/silverblue.png
Binary file added src/icons/slackware.png
Binary file added src/icons/solus.png
Binary file added src/icons/steamos.png
Binary file added src/icons/type.png
Binary file added src/icons/tz.png
Binary file added src/icons/ubuntu.png
Binary file added src/icons/ultramarine.png
Binary file added src/icons/unknown.png
Binary file added src/icons/unset.png
Binary file added src/icons/vanillaos.png
Binary file added src/icons/ventoy.png
Binary file added src/icons/void.png
Binary file added src/icons/windows.png
Binary file added src/icons/xero.png
Binary file added src/icons/xerolinux.png
Binary file added src/icons/xubuntu.png
Binary file added src/icons/zorin.png
Empty file added src/msjh24.pf2
Empty file.
Empty file added src/msyh16.pf2
Empty file.
Empty file added src/msyh64.pf2
Empty file.
45 changes: 45 additions & 0 deletions src/theme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Global Property
title-text: ""
desktop-color: "#2165b5"
terminal-left: "0"
terminal-top: "0"
terminal-width: "100%"
terminal-height: "100%"
terminal-border: "0"
terminal-font: "GNU Unifont Regular 16"

# Show the boot menu
+ boot_menu {
left = 8%
top = 17%
width = 500
height = 70%
item_font = "Microsoft JhengHei Regular 24"
item_color = "#ffffff"
icon_width = 128
icon_height = 128
item_icon_space = 10
item_height = 144
item_padding = 10
item_spacing = 10
selected_item_pixmap_style = "frame_*.png"
}

# Show a countdown message using the label component
+ label {
top = 13%
left = 9%
width = 30%
id = "__timeout__"
font = "Microsoft YaHei Regular 16"
text = "HOST_DISTRO 将在 %d 秒 内自动运行。"
color = "#ffffff"
}

+ label {
text = "选择操作系统"
font = "Microsoft YaHei Regular 64"
top = 3%
left = 9%
color = "#ffffff"
}

0 comments on commit 2d0c991

Please sign in to comment.