2M
今天升级了一下台式机的显示器为三星LS27D806UACXXF, 这是一块4k高清屏,连接后完美驱动。但是由于分辨率由1920x1080提高到3849x2160, ArchLinux下Gnome3自适应了高分屏,但是还需要做一些设置才能完美使用。
系统缩放设置
系统→显示器→选择屏幕→200%
GDM 登陆界面的 4K HiDPI 缩放设置
在使用 4K 显示器时,我通常会把 Gnome 桌面的缩放设置为 200%,这样看起来眼睛不会太累。但每次开机时会发现 GDM 登陆界面并没有使用这个缩放值,还是按 100% 无缩放的效果显示的。我希望登陆界面也能使用和桌面一样的缩放值。
解决方法
1
2
| cp /home/feng/.config/monitors.xml /var/lib/gdm/.config/
chown gdm:gdm /var/lib/gdm/.config/monitors.xml
|
{% note primary %}
在执行上述命令时,先使用su切换到root,然后再运行。其中第二条命令设置了文件的所属用户和用户组。重启系统,登录界面和桌面一样,使用2倍的缩放显示。
{% endnote %}
参考文章
GDM 登陆界面的 4K HiDPI 缩放设置
GRUB 的高分屏设置
1. 安装 whitesur 4k 主题
1
2
3
| git clone https://github.com/vinceliuice/grub2-themes.git
cd ./grub2-themes
sudo ./install.sh -t whitesur -s 4k -i whitesur
|
{% note primary %}
注意:在安装主题时,如果之前已经安装并且修改过,那请一定将/etc/grub/config中的GRUB_FONT行注释掉,否则生成会出错。所以这应当作为首要步骤检查!!
{% endnote %}
2. 将字体转换为 GRUB 可读格式
鉴于引导前环境的限制,GRUB 字体经过优化,以确保易读性和简洁性。它们不具备在完全加载的操作系统中使用的字体所具有的抗锯齿或印刷级别的优化。所以您不能简单地将 TTF、OTF、WOFF 等格式的字体直接用于 GRUB, 可以借助 grub-mkfont 命令将几乎任何字体转换为 GRUB 兼容的格式。
由于在中文环境下菜单会出现中文,所以应当选择那些同时支持中文和英文的字体。因为启动过程中会有终端输出信息,所以我们选择与终端中使用相同的字体DroidSansMono Nerd Fonts.
1
2
3
4
5
| sudo pacman -S nerd-fonts
sudo grub-mkfont -v --output=/usr/share/grub/themes/whitesur/dsmfm40.pf2 --size=40 /usr/share/fonts/OTF/DroidSansMNerdFontMono-Regular.otf
sudo grub-mkfont -v -s 40 -o /usr/share/grub/themes/whitesur/dvsm40.pf2 /usr/share/fonts/TTF/DejaVuSansMono.ttf
sudo grub-mkfont -v -s 40 -o /usr/share/grub/themes/whitesur/wqy40.pf2 /usr/share/fonts/wenquanyi/wqy-microhei/wqy-microhei.ttc
sudo grub-mkfont -v -s 40 -o /usr/share/grub/themes/whitesur/msyh40.pf2 /usr/share/fonts/Windows11/msyh.ttc
|
{% note primary %}
因为自定义安装了whitesur主题, 所以将生成的字体保存在相应的目录/usr/share/grub/themes/whitesur/. 此处生成了多个字体,但是由于生成GRUB配置文件时,有时不显示中文,而微软雅黑是一款中英文都支持的比较全的字体,当切换到它时一定可以同时显示中英文,只是终端输出时不太好看。然后,切换到DejaVuSansMono时,GRUB仍然可以正常显示中文,详细原因不是很清楚,暂时这样使用。2024-10-17 21:40
{% endnote %}
3. 修改 GRUB 配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| # GRUB boot loader configuration
GRUB_DEFAULT=0
# GRUB_DEFAULT=saved
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=0 quiet nvidia-drm.modeset=1"
GRUB_CMDLINE_LINUX=""
# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y
# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu
# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console
# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `videoinfo'
GRUB_GFXMODE=3840x2160,auto
# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep
# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
# Uncomment one of them for the gfx desired, a image background or a gfxtheme
GRUB_BACKGROUND="/usr/share/grub/themes/whitesur/background.jpg"
GRUB_THEME="/usr/share/grub/themes/whitesur/theme.txt"
# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"
GRUB_FONT="/usr/share/grub/themes/whitesur/dvsm40.pf2"
# Uncomment to make GRUB remember the last selection. This requires
# setting 'GRUB_DEFAULT=saved' above.
# GRUB_SAVEDEFAULT=true
# Uncomment to disable submenus in boot menu
# GRUB_DISABLE_SUBMENU=y
# Probing for other operating systems is disabled for security reasons. Read
# documentation on GRUB_DISABLE_OS_PROBER, if still want to enable this
# functionality install os-prober and uncomment to detect and include other
# operating systems.
GRUB_DISABLE_OS_PROBER=false
|
{% note primary %}
注意:GRUB_FONT使用绝对路径为上一步生成的字体所在位置,同时GRUB_GFXMODE修改为当前的分辨率3840x2160, auto.
{% endnote %}
4. 修改主题字体配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# GRUB2 gfxmenu Linux theme
# Designed for any resolution
# Global Property
title-text: ""
desktop-image: "background.jpg"
desktop-color: "#000000"
terminal-font: "DejaVu Sans Mono Regular 40"
terminal-box: "terminal_box_*.png"
terminal-left: "0"
terminal-top: "0"
terminal-width: "100%"
terminal-height: "100%"
terminal-border: "0"
# Show the boot menu
+ boot_menu {
left = 30%
top = 30%
width = 40%
height = 40%
item_font = "DejaVu Sans Mono Regular 40"
item_color = "#cccccc"
selected_item_color = "#ffffff"
icon_width = 64
icon_height = 64
item_icon_space = 36
item_height = 80
item_padding = 12
item_spacing = 24
selected_item_pixmap_style = "select_*.png"
}
+ image {
top = 100%-100
left = 50%-480
width = 960
height = 84
file = "info.png"
}
# Show a countdown message using the label component
+ label {
top = 82%
left = 32%
width = 36%
align = "center"
id = "__timeout__"
text = "Booting in %d seconds"
color = "#cccccc"
font = "DejaVu Sans Mono Regular 40"
}
|
{% note primary %}
注意:在配置文件theme.txt文件中字体使用的是字体名字,它由grub-mkfont命令生成GRUB字体时的-v选项给出,也可以由fc-list |grep msyh.ttc 查询到,然后加上生成字体的字号40或其他值即可。
{% endnote %}
5. 更新 GRUB 配置
1
| sudo grub-mkconfig -o /boot/grub/grub.cfg
|
6. BUG 暂存
当设置GRUB为4k时,启动特别慢,已经确定是GRUB的BUG, 所以暂时使用现有配置待上游作者修复BUG后再更新。
7. 参考文章