xrandr 大小 1920x1080 在可用模式 ubuntu 中找不到

Aso*_*ife 2 bash ubuntu matlab highdpi

我使用的是配备 4k 显示屏的 Dell XPS 15 9550,操作系统为 ubuntu。我需要使用 Matlab,但我(一如既往)遇到了 HighDPI 问题。目前我使用的是r2017a版本的Matlab。

为了解决这个问题,我尝试使用一个小脚本来避免这个问题:

Myscript.sh

#!/bin/sh

#set scaling to x1.0 to remove the zoom used in HDPI screens
gsettings set org.gnome.desktop.interface scaling-factor 1
#Used in ubuntu machines
gsettings set com.ubuntu.user-interface scale-factor "{'HDMI1': 8, 'eDP1': 8}"
#applying full HD resolution
xrandr -s 1920x1080
# call your program
/usr/local/MATLAB/R2017a/bin/matlab
#wait for the process to terminate
wait
#now coming back to the original screen resolution and scaling
# set scaling to x2.0
gsettings set org.gnome.desktop.interface scaling-factor 2
#same as before
gsettings set com.ubuntu.user-interface scale-factor "{'HDMI1': 8, 'eDP1': 16}"
#back to original resolution
xrandr -s 3840x2160
Run Code Online (Sandbox Code Playgroud)

当我启动它时,我从控制台收到此错误:

“在可用模式中找不到尺寸 1920x1080”

所以我做了:

cvt 1920 1080 60
Run Code Online (Sandbox Code Playgroud)

输出:

# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
Run Code Online (Sandbox Code Playgroud)

在那之后:

xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
Run Code Online (Sandbox Code Playgroud)

最后

xrandr --addmode eDP-1-1 1920x1080
Run Code Online (Sandbox Code Playgroud)

我使用 xrandr -q 找到了 eDP-1-1。这里的输出

Screen 0: minimum 8 x 8, current 3840 x 2160, maximum 16384 x 16384
eDP-1-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 346mm x 194mm
  3840x2160     60.00*+
   2048x1536     60.00  
   1920x1440     60.00  
   1856x1392     60.01  
   1792x1344     60.01  
   1920x1200     59.95  
   1920x1080     59.93  
   1600x1200     60.00  
   1680x1050     59.95    59.88  
   1600x1024     60.17  
   1400x1050     59.98  
   1280x1024     60.02  
   1440x900      59.89  
   1280x960      60.00  
   1360x768      59.80    59.96  
   1152x864      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   960x600       60.00  
   960x540       59.99  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   800x512       60.17  
   700x525       59.98  
   640x512       60.02  
   720x450       59.89  
   640x480       60.00    59.94  
   680x384       59.80    59.96  
   576x432       60.06  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
DP-1-2 disconnected (normal left inverted right x axis y axis)
HDMI-1-2 disconnected (normal left inverted right x axis y axis)
Run Code Online (Sandbox Code Playgroud)

所以我认为我已经做了所有正确的事情,但脚本仍然不起作用,控制台仍然给我同样的错误。

我做错什么了吗?

Jon*_*rdo 6

我的 4k 屏幕也有同样的问题。我执行了您描述的所有步骤,但不是:

#applying full HD resolution
xrandr -s 1920x1080
Run Code Online (Sandbox Code Playgroud)

我用过这个:

xrandr --output eDP-1-1 --mode 1920x1080
Run Code Online (Sandbox Code Playgroud)

它工作完美。

另外,如果您仅在 Matlab 中使用 4k 屏幕时遇到问题,您可以考虑通过在 Matlab 终端中键入以下命令来更改 Matlab 中的缩放比例:

s = settings;s.matlab.desktop.DisplayScaleFactor
s.matlab.desktop.DisplayScaleFactor.PersonalValue = 2
Run Code Online (Sandbox Code Playgroud)

该设置只有在重新启动matlab后才会生效。

我在 Linux 中的 HiDPI 屏幕的主要来源是Archwiki。他们提供清晰详细的信息。