在 Ubuntu 20.04 上,我有 2 个屏幕,一个 4K(3840x2160)电视和一个 1080p 显示器。我想让它们镜像,电视作为主屏幕,1080p 作为备用屏幕。我希望图像在两个屏幕上都以 4k 渲染,这样它们显示的效果完全相同。通过显示设置,我只能在两个屏幕上选择最高 1080p,所以我一直在尝试使用xrandr
,但没有成功。我能实现的最多是在两个屏幕上渲染 4k,但 1080p 屏幕会裁剪图像并仅显示 1/4 的图像。
xrandr --prop
:
HDMI-0 connected (normal left inverted right x axis y axis)
CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 1
CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0
EDID:
00ffffffffffff0061a4e20001000000
0a1d0103806f3e780acf74a3574cb023
09484c21080081804540614095000101
010101010101023a801871382d40582c
4500c48e2100001e662150b051001b30
40703600c48e2100001e000000fc004d
692054560a20202020202020000000fd
00324b1e5017000a2020202020200150
02033df251010304050790121314161f
5d5e5f6263642f097f07150750570600
3d06c05f7e01830100006e030c001000
b83c20008001020304e3060501011d00
bc52d01e20b8285540c48e2100001e01
1d80d0721c1620102c2580c48e210000
9e000000000000000000000000000000
000000000000000000000000000000bc
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: TMDS
supported: TMDS
ConnectorType: HDMI
ConnectorNumber: 1
_ConnectorLocation: 1
non-desktop: 0
supported: 0, 1
1920x1080 60.00 + 59.94 50.00 60.00 50.04
4096x2160 29.97 25.00 24.00 23.98
3840x2160 29.97 25.00 23.98 23.98
1440x900 59.89
1360x768 60.02
1280x1024 60.02
1280x720 59.94 50.00
1024x768 60.00
800x600 60.32
720x576 50.00
720x480 59.94
640x480 59.94 59.93
HDMI-1-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
_MUTTER_PRESENTATION_OUTPUT: 0
EDID:
00ffffffffffff0010acdad042394435
2b1d010380351e78ea0565a756529c27
0f5054a54b00714f8180a9c0d1c00101
010101010101023a801871382d40582c
45000f282100001e000000ff00484c36
593159320a2020202020000000fc0044
454c4c205032343139480a20000000fd
00384c1e5311000a20202020202001fb
020317b14c9005040302071601141f12
1365030c001000023a801871382d4058
2c45000f282100001e011d8018711c16
20582c25000f282100009e011d007251
d01e206e2855000f282100001e8c0ad0
8a20e02d10103e96000f282100001800
00000000000000000000000000000000
0000000000000000000000000000003d
PRIME Synchronization: 0
supported: 0, 1
HDCP Content Type: HDCP Type0
supported: HDCP Type0, HDCP Type1
Content Protection: Undesired
supported: Undesired, Desired, Enabled
max bpc: 12
range: (8, 12)
content type: No Data
supported: No Data, Graphics, Photo, Cinema, Game
Colorspace: Default
supported: Default, SMPTE_170M_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, opRGB, BT2020_CYCC, BT2020_RGB, BT2020_YCC, DCI-P3_RGB_D65, DCI-P3_RGB_Theater
aspect ratio: Automatic
supported: Automatic, 4:3, 16:9
Broadcast RGB: Automatic
supported: Automatic, Full, Limited 16:235
audio: auto
supported: force-dvi, off, auto, on
link-status: Good
supported: Good, Bad
CONNECTOR_ID: 74
supported: 74
non-desktop: 0
range: (0, 1)
1920x1080 60.00*+ 50.00 59.94
1920x1080i 60.00 50.00 59.94
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1280x720 60.00 50.00 59.94
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x576i 50.00
720x480 60.00 59.94
720x480i 60.00 59.94
640x480 75.00 60.00 59.94
720x400 70.08
3840x2160_60.00 60.00
3840x2160_29.97 29.97
我试过:
xrandr --fb 3840x2160 --output HDMI-0 --rate 29.97 --mode 3840x2160 --output HDMI-1-1 --rate 29.97 --mode 1920x1080 --panning 0x0 --scale 2x2
也:
xrandr --fb 3840x2160 --output HDMI-0 --rate 29.97 --mode 3840x2160 --output HDMI-1-1 --rate 29.97 --mode "3840x2160_29.97" --panning 0x0
其中“3840x2160_29.97”是以下结果gtf
:
gtf 3840 2160 29.97
我的目标是否可以通过 实现xrandr
?我该怎么做?如果 无法实现xrandr
,还有其他方法吗?
答案1
#!/bin/bash
mode="3840x2160_60.00"
screen="HDMI1"
cvt_res="712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync"
if [[ "$(xrandr|grep $mode)" ="" ]];
then
xrandr --newmode $mode $cvt_res &&
xrandr --addmode $screen $mode
fi
xrandr --output HDMI-0 --mode "3840x2160" --output $screen --mode "1920x1080" --scale 2.0x2.0 --panning 3840x2160
执行上述操作后,UHD 屏幕中的内容会缩放,但屏幕的 3/4 是黑色的。之后,我手动进入显示设置,将两个显示器更改为镜像 3840x2160,此时就达到了所需的结果。但不幸的是,每次启动时都需要这样做!
附言:这是来源我用了。
编辑:看起来是自动生成的(由 Nvidia)xorg.conf
导致了问题!