Gnome Shell 字体缩放重置

Luc*_*uca 6 gnome-shell 20.04

我使用的是Ubuntu 20.04Linux Kernel 5.7.10-050710-genericGNOME Shell 3.36.3

我已将字体缩放因子设置为1.25但最近当缩放因子持续到 UI 时重新启动时,它不适用于 gnome shell。

为了使其再次工作,我必须再次手动将其重置1.25

有什么建议?

Mic*_*lis 5

我也遇到过这种情况,使用全新的 Ubuntu 20.04 安装。我看到了这个问题的根本原因(https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1892440)。

我可以提供我的解决方法:添加到自动启动一个简单的命令,该命令在登录后显式设置“文本缩放因子”。GNOME shell 会正确注意到此更改,从而正确缩放 GNOME shell 文本。

为此,请创建一个$HOME/.config/autostart/fix-font-scaling.desktop包含以下内容的文件:

[Desktop Entry]
Name=Fix Font Scaling
GenericName=Fix Font Scaling
Exec=/home/michalis/bin/fix-font-scaling.sh
Terminal=false
Type=Application
StartupNotify=false
X-GNOME-Autostart-enabled=true
Run Code Online (Sandbox Code Playgroud)

哪里/home/michalis/bin/只是一个例子,它是我保存脚本的地方。

然后制作一个/home/michalis/bin/fix-font-scaling.sh包含如下内容的脚本:

#!/bin/bash
set -eu

# wait a bit, otherwise the change seems to not be noticed properly
sleep 1s
# change to 1.5 then to 1.25, it seems necessary for GNOME shell to register this "change"
gsettings set org.gnome.desktop.interface text-scaling-factor 1.5
gsettings set org.gnome.desktop.interface text-scaling-factor 1.25
Run Code Online (Sandbox Code Playgroud)

使其可执行 ( chmod +x /home/michalis/bin/fix-font-scaling.sh)。

并根据需要调整上面的 1.25。

请注意,这会覆盖您通过设置(“辅助功能 -> 大文本”或 GNOME 调整工具“文本缩放”)设置的文本缩放。


注意:有什么作用set -eu

它使编写 bash 脚本更安全,所以我学会了在我所有的 bash 脚本中自动使用它:)

这是一个快捷方式set -eset -u

  • set -e意味着一旦某些命令以非零状态退出,bash 脚本将以非零状态退出。例如,如果sleep命令由于任何奇怪的原因失败,则gsettings不会执行以下调用。没有set -e,bash 脚本会愉快地继续执行,即使在执行过程中报告失败时也是如此。

  • set -u意味着当您尝试使用未定义的变量(如echo ${SOMETHING_UNDEFINED}. 因此set -u可以更轻松地捕获脚本中的错误。它在这个不使用变量的特定脚本中没有任何影响:) 使用它只是我的习惯力量。

http://redsymbol.net/articles/unofficial-bash-strict-mode/上有一篇很棒的文章讨论了这个(以及一些相关的)bash 构造,使 bash 脚本更容易编写/调试。