环境:archLinux + i3wm
台式电脑连接两块显示器,i3wm 需要使用 xrandr 命令指定输出到其他显示器,但是每次开机后 xrandr 结果是不固定的,在两种情况下徘徊。因此我在 i3wm 的配置文件需要常常切换,具体配置如下所示:
## multi monitors
#exec --no-startup-id xrandr --output DP-3 --primary
#exec --no-startup-id xrandr --output DP1 --auto --left-of DP-3 --mode 1920x1080 --rotate normal
#workspace 1 output DP1
exec --no-startup-id xrandr --output DP-2 --primary
exec --no-startup-id xrandr --output DP3 --auto --left-of DP-2 --mode 1920x1080 --rotate normal
workspace 1 output DP3
目前的 xrandr 结果如下所示:
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
DP-1 disconnected primary (normal left inverted right x axis y axis)
DP-2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+
1680x1050 60.00
1600x900 60.00
1280x1024 75.02 60.02
1440x900 60.00
1280x800 60.00
1152x864 75.00
1280x720 60.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
HDMI-2 disconnected (normal left inverted right x axis y axis)
DP3 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 510mm x 290mm
1920x1080 60.00*+
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x48) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
1280x1024 (0x4b) 135.000MHz +HSync +VSync
h: width 1280 start 1296 end 1440 total 1688 skew 0 clock 79.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 75.02Hz
1280x1024 (0x4c) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1152x864 (0x4f) 108.000MHz +HSync +VSync
h: width 1152 start 1216 end 1344 total 1600 skew 0 clock 67.50KHz
v: height 864 start 865 end 868 total 900 clock 75.00Hz
1024x768 (0x51) 78.750MHz +HSync +VSync
h: width 1024 start 1040 end 1136 total 1312 skew 0 clock 60.02KHz
v: height 768 start 769 end 772 total 800 clock 75.03Hz
1024x768 (0x52) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x53) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x54) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
640x480 (0x55) 31.500MHz -HSync -VSync
h: width 640 start 656 end 720 total 840 skew 0 clock 37.50KHz
v: height 480 start 481 end 484 total 500 clock 75.00Hz
640x480 (0x56) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
720x400 (0x57) 28.320MHz -HSync +VSync
h: width 720 start 738 end 846 total 900 skew 0 clock 31.47KHz
v: height 400 start 412 end 414 total 449 clock 70.08Hz
请教各位,有啥好办法?
1
raaaaaar 2020-12-17 12:05:17 +08:00 via Android 1
我也是这个系统的图形界面,不过没有搞过多显示器,所以没遇到过。
但是如果是每次开机名字都变,那写个脚本获取这个名字,再继续用那个命令不行么 |
2
no1xsyzy 2020-12-17 12:12:12 +08:00
先来点很毒的 workaround:
在 i3 启动之前先通过 xrandr 的输出确定两台显示器的名称并写配置。 |
3
nightwitch 2020-12-17 12:14:28 +08:00
写个脚本,xrander | grep "connected",然后把显示器的名字填到 i3wm 的配置文件里
|
4
Jeansh 2020-12-17 12:14:39 +08:00 1
能不能先 xrandr --listmonitors,然后判断再配置,没有多显示器,没法测试。
|
5
no1xsyzy 2020-12-17 12:14:47 +08:00 1
|
6
no1xsyzy 2020-12-17 12:15:45 +08:00
@nightwitch 你陷坑了,connected 是 disconnected 的子串……
|
7
Jeansh 2020-12-17 12:15:58 +08:00
@nightwitch 哈哈。grep connected 会把 disconnected 的一并显示。
|
8
Jeansh 2020-12-17 12:23:22 +08:00
xrandr|grep connected|grep -v disconnected|awk '{print $1}'
|
9
bluehtt OP |