int*_*ika 5 desktop gnu-screen x11 xrandr resolution
在使用 Xorg X11 时,在 KDE/Gnome/XFCE上,我们如何缩放整个桌面和/或每个应用程序的显示/分辨率?(当这在设置 GUI 上不可用时)
目的是保持屏幕分辨率不变(最大),同时缩放桌面/应用程序的大小(更大/更小)。
int*_*ika 11
这详细介绍了 Linux 的显示是如何工作的?质量保证。
在大多数桌面系统(如 KDE 或 Gnome)上,它们各自的设置面板上都有可用的设置,本指南用于附加/手动设置,可用于扩展应用程序或整个桌面。这篇参考文章有很多关于此事的有价值的信息。
缩放应用程序可以主要通过 DPI、特定环境变量(解释如下)、应用程序自己的设置或一些特定的桌面设置(超出本 QA 的范围)来完成。
Qt 应用程序可以使用以下环境变量进行缩放,请注意,许多应用程序是硬编码大小和字体,因此此类应用程序的结果可能与预期不符。
export QT_AUTO_SCREEN_SET_FACTOR=0
export QT_SCALE_FACTOR=2
export QT_FONT_DPI=96
Run Code Online (Sandbox Code Playgroud)
Gnome/GTK 应用程序可以使用以下环境变量进行扩展
export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
Run Code Online (Sandbox Code Playgroud)
Gnome/GTK 也可以使用此 Gnome 设置进行全局缩放
gsettings set org.gnome.desktop.interface text-scaling-factor 2.0
Run Code Online (Sandbox Code Playgroud)
Chromium,可以使用以下命令进行缩放
chromium --high-dpi-support=1 --force-device-scale-factor=1.5
Run Code Online (Sandbox Code Playgroud)
Xpra (python) 可以与Run scaled一起使用以实现每个应用程序的缩放。
~/.profile登录后可以为全局和自动设备放置环境变量修改。
Xorg的扩展 RandR 具有缩放功能,可以使用xrandr. 这可用于缩放桌面以显示更大的环境,这对于 HiDPI(每英寸高点数)显示器很有用。
RandR也可以反过来使用,例如使最大分辨率为 1366x768 的屏幕支持更大的分辨率,如 1920x1080。这是通过模拟新的更高分辨率同时以支持的最大分辨率进行渲染来实现的,类似于我们在非全高清屏幕上观看全高清视频。
获取屏幕名称:
xrandr | grep connected | grep -v disconnected | awk '{print $1}'
Run Code Online (Sandbox Code Playgroud)
将屏幕尺寸缩小20%(放大)
xrandr --output screen-name --scale 0.8x0.8
Run Code Online (Sandbox Code Playgroud)
将屏幕尺寸增加20%(缩小)
xrandr --output screen-name --scale 1.2x1.2
Run Code Online (Sandbox Code Playgroud)
重置xrandr更改
xrandr --output screen-name --scale 1x1
Run Code Online (Sandbox Code Playgroud)
当使用前一种方法xrandr“放大”时,桌面保持全屏,但是当我们“缩小”例如(以获得不受支持的分辨率)时,桌面不会全屏显示,因为这需要更新分辨率(由屏幕可能更高的分辨率不支持),我们可以使用的combinaison ,并且,xrandr的参数来实现全屏幕“缩小”比例(模拟新的分辨率),例如:xrandr --output screen-name --scale 1.2x1.2--mode--panning--scale
获取当前设置
xdpyinfo | grep -B 2 resolution
# or
xdpyinfo
Run Code Online (Sandbox Code Playgroud)
配置示例
Scaling at: 120%
Used/max screen resolution: 1366 x 768
Resolution at 120% (res x 1.2): 1640 x 922 (round)
Scaling factor (new res / res): 1.20058565 x 1.20208604
Run Code Online (Sandbox Code Playgroud)
这里的想法是虚拟地增加屏幕分辨率(因为我们在物理上被限制为 1366x768)命令将是 (replace screen-name):
xrandr --output screen-name --mode 1366x768 --panning 1640x922 --scale 1.20058565x1.20208604
Run Code Online (Sandbox Code Playgroud)
重置更改
xrandr --output screen-name --mode 1366x768 --panning 1366x768 --scale 1x1
# restarting the desktop may be required example with KDE
# kquitapp5 plasmashell
# plasmashell &
Run Code Online (Sandbox Code Playgroud)
有多种方法可以使xrandr更改持久化,this和this QA 有很多示例。
作为使用 SDDM + KDE 时的旁注和实验结果,经过多次测试以实现持久配置,我最终使用~/.config/autostart( systemsettings5> Startup...> Autostart)加载脚本,并命名我的脚本00-scriptname以使其首先运行。
# 00-scriptname
# Applying the main xrandr suited changes (scaling at x1.15)
xrandr --output eDP1 --mode 1366x768 --panning 1574x886 --scale 1.15226939x1.15364583
# This is where it get odd/complicated, sometimes the screen resolution is not applied correctly or not applied at all...
# Note that "xrandr --fb" can be used alone to change the screen resolution on a normal situation...
# Here we will be taking advantage of xrandr's "--fb" feature to make the config appliance stable and works every-time.
# The odd thing here is while re-applying the new resolution 1574x886 with "--fb" nothing happen, but
# if we use use an unsupported resolution like 1574x884 (vs 1574x886) then xrandr force the resolution
# to "reset itself" to the configured resolution (1574x886)...
# In short just re-apply the setting with "--fb" and an unsupported resolution to force a reset.
# ("--fb" can be used alone here without re-applying everything)
#xrandr --fb 1574x884
xrandr --fb 1574x884 --output eDP1 --mode 1366x768 --panning 1574x886 --scale 1.15226939x1.15364583
Run Code Online (Sandbox Code Playgroud)
一些 KDE 的 gui 工具: systemsettings5 > 显示,kcmshell5 xserver和kinfocenter.
链接和来源:
1、
2、
3、
4、
5、
6、
7、
8、
9、
10、
11和
12。
xrandr --scale因为它会产生不同的分辨率(模糊)我建议切换到“Wayland”而不是“X11”,因为 xrandr --scale 将光栅化的帧错误位图缩放到屏幕分辨率,这与向屏幕发送不同的分辨率相同模糊,请参阅https:// /gitlab.freedesktop.org/xorg/xserver/-/issues/1205了解详细信息。
要切换到 Waylayland,可能需要删除 nvidia 驱动程序并切换到开源驱动程序 ( nouveau )。
在 Wayland 上,您可以针对不同的屏幕使用不同的比例,而无需更改分辨率(与 x11 不同),Wayland 还允许分形缩放(与 X11 不同)[ REF ]。
gnome-control-center>Settings>Display>Scale

gnome-tweaks>Fonts>Scaling Factor
