Mal*_*rba 24 multiple-monitors ubuntu
由于我找到了一种不同的方法来实现我的目标,并且由于我之前的问题没有发布任何答案,因此我更改了问题以匹配我找到的答案。
有没有办法完全从命令行关闭笔记本电脑的显示器并打开外接显示器(反之亦然)?
Mal*_*rba 33
随着命令
xrandr --output VGA-0 --auto
xrandr --output LVDS --off
Run Code Online (Sandbox Code Playgroud)
屏幕自动转移到外接显示器。它甚至不需要 sudo 权限。要找出显示器的名称,只需执行以下操作:
xrandr -q
Run Code Online (Sandbox Code Playgroud)
这应该给出类似的东西:
VGA-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
...
LVDS connected (normal left inverted right x axis y axis)
...
Run Code Online (Sandbox Code Playgroud)
可以用类似的方式扩展显示器。
小智 5
这肯定不是对您问题的直接回答。但我发现它对我的用例很有帮助。这不是配置文件的导出,但它确实展示了如何在 shell 脚本中自动分散。我将其设置为每次对接/取消对接时运行,它似乎解决了对接和取消对接笔记本电脑时的显示问题:
您必须安装分散和 Python。
#!/bin/sh
#
# Detect displays and move panels to the primary display
#
PYTHON=python2.6
DISPER=/usr/bin/disper
# disper command will detect and configure monitors
$PYTHON $DISPER --displays=auto -e -t left
# parse output from disper tool how many displays we have attached
# disper prints 2 lines per displer
lines=`$PYTHON $DISPER -l|wc -l`
display_count=$((lines / 2))
echo $display_count
echo "Detected display count:" $display_count
# Make sure that we move panels to the correct display based
# on the display count
if [ $display_count = 1 ] ; then
echo "Moving panels to the internal LCD display"
gconftool-2 \
--set "/apps/panel/toplevels/bottom_panel_screen0/monitor" \
--type integer "0"
gconftool-2 \
--set "/apps/panel/toplevels/top_panel_screen0/monitor" \
--type integer "0"
sleep 5
pkill gnome-panel
else
echo "Moving panels to the external display"
gconftool-2 \
--set "/apps/panel/toplevels/top_panel_screen0/monitor" \
--type integer "1"
gconftool-2 \
--set "/apps/panel/toplevels/bottom_panel_screen0/monitor" \
--type integer "1"
sleep 5
pkill gnome-panel
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33808 次 |
| 最近记录: |