Ato*_*ius 3 xubuntu display multiple-monitors
我在 DP KVM 交换机的 xubuntu 16.04 上有一个带有 2 个屏幕(笔记本 T460s 本身为 3 个)的多显示器设置。笔记本电脑通过 Dock-3 扩展坞通过 2 个 DP 端口连接。
每次我从台式机切换到笔记本电脑时,显示器配置都会丢失,所以我必须从头开始配置它,包括激活单个显示器。如果笔记本连接了扩展坞,有没有办法保存这些配置并自动恢复?
xrandr连接屏幕的(缩短的)输出:
Screen 0: minimum 8 x 8, current 6800 x 1440, maximum 32767 x 32767
eDP1 connected 2560x1440+4240+0 (normal left inverted right x axis y axis) 310mm x 170mm
2560x1440 60.00*+ 48.00
1920x1440 60.00
.........
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 connected 1680x1050+2560+0 (normal left inverted right x axis y axis) 473mm x 296mm
1680x1050 59.88*+ 59.95
1920x1080 60.00 50.00 59.94
..........
DP2-2 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
2560x1440 59.95*+
1920x1200 59.95
..........
DP2-3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
Run Code Online (Sandbox Code Playgroud)
您面临的问题并非 16.04 独有,它发生在许多 Ubuntu 版本上。
阅读你的输出xrandr,并假设我没有打错字,下面的命令应该按照你设置的方式排列你的屏幕:
xrandr --output DP2-2 --auto --pos 0x0 --output DP2-1 --auto --pos 2560x0 --output eDP1 --auto --pos 4240x0
Run Code Online (Sandbox Code Playgroud)
最快和最简单的解决方案是将其添加到快捷键:设置 > 键盘 > 应用程序快捷方式。然后在屏幕连接后按快捷方式。
从 的输出中xrandr,我们可以看到三个连接屏幕的信息:
eDP1 connected 2560x1440+4240+0
DP2-1 connected 1680x1050+2560+0
DP2-2 connected primary 2560x1440+0+0
Run Code Online (Sandbox Code Playgroud)
在最后一部分:2560x1440+4240+0,在部分: 中+4240+0,我们可以看到屏幕在组合屏幕(x,y)的整个图片中的位置。从左到右,屏幕显然是这样排列的:
DP2-2 +0+0 | DP2-1 +2560+0 | eDP1 +4240+0
Run Code Online (Sandbox Code Playgroud)
如果没有自动记住这种安排,我们可以使用我在本答案开头添加的命令进行设置。
--auto我添加的选项,因为您提到还必须激活屏幕。
根据要求,如果屏幕已连接,将在后台运行一个小的 bash 脚本以进行设置:
eDP1 connected 2560x1440+4240+0
DP2-1 connected 1680x1050+2560+0
DP2-2 connected primary 2560x1440+0+0
Run Code Online (Sandbox Code Playgroud)
setup_scr.sh,使其可执行使用以下命令在终端中测试运行它:
/path/to/setup_scr.sh
Run Code Online (Sandbox Code Playgroud)
连接/断开屏幕
如果工作正常,请将其添加到启动应用程序:Dash > Startup Applications > Add。添加命令:
/bin/bash -c "sleep 15 && /path/to/setup_scr.sh"
Run Code Online (Sandbox Code Playgroud)该脚本每 4 秒计算一次连接屏幕的数量。如果它等于 3,它会运行一次设置,记住它确实通过将“swon”(打开)的值切换为 来设置屏幕true。
然后如果屏幕数不再等于 3,则false再次设置“swon” ,以此类推。
我在我的双屏幕设置上测试了脚本,它运行良好,但是,我总是有可能在某处打错了字,显然我无法在你的系统上测试它。如有错误,请指出。
小智 5
这些答案仅与恢复有关。要“保存”当前状态,您可以使用此脚本(dump_randr.sh)
#!/bin/bash
fileName="$1"
while read -r line; do
IFS=" "
entry=( $line )
display=${entry[0]}
IFS="x+"
if [[ "${entry[2]}" == primary ]]; then
primary=1
measurement=( ${entry[3]} )
else
primary=0
measurement=( ${entry[2]} )
fi
unset IFS
width=${measurement[0]}
height=${measurement[1]}
left=${measurement[2]}
top=${measurement[3]}
xrandrOpt="$xrandrOpt --output $display --mode ${width}x${height} --pos ${left}x${top}"
((primary)) && xrandrOpt="$xrandrOpt --primary"
done < <(xrandr | grep " connected")
echo "#!/bin/bash" > "$fileName"
echo "xrandr $xrandrOpt" > "$fileName"
chmod +x "$fileName"
Run Code Online (Sandbox Code Playgroud)
这将转储当前的 xrandr 选项以再次使用它们。您可以执行以下操作来存储当前设置:
dump_randr.sh 2_monitors_home.sh
Run Code Online (Sandbox Code Playgroud)
它创建2_monitors_home.sh以恢复当前状态。
| 归档时间: |
|
| 查看次数: |
3268 次 |
| 最近记录: |