我的笔记本是thinkpad,外接显示器设置分辨率为1680x1050.
首先,熟悉一下命令:
xrandr 命令行可以很方便地切换双屏,常用方式如下,其他的可以自己探索:
xrandr --output VGA --same-as LVDS --auto
打开外接显示器(最高分辨率),与笔记本液晶屏幕显示同样内容(克隆)
xrandr --output VGA --same-as LVDS --mode 1024x768
打开外接显示器(分辨率为1024x768),与笔记本液晶屏幕显示同样内容(克隆)
xrandr --output VGA --right-of LVDS --auto
打开外接显示器(最高分辨率),设置为右侧扩展屏幕
xrandr --output VGA --off
关闭外接显示器
xrandr --output VGA --auto --output LVDS --off
打开外接显示器,同时关闭笔记本液晶屏幕(只用外接显示器工作)
xrandr --output VGA --off --output LVDS --auto
关闭外接显示器,同时打开笔记本液晶屏幕 (只用笔记本液晶屏)
然后,按照下面的方法设置一遍。
1,
$cvt 1440 900
结果如下
# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
Modeline "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
Modeline后面的值在下边要用。然后执行
2,
$xrandr
得到显示器名称,我的为 VGA1,笔记本为LVDS1,大家以此类推,不一定都一样
3,
$sudo xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
参数就是cvt结果中Modeline后面的那一堆,根据自己的参数调整。
4,
$xrandr
就可 以看到新加的那个设置了。
然后添加新的mode,执行
5,
$sudo xrandr --addmode VGA1 "1440x900_60.00"
然后设置一下就行了,大家看看xrandr的命令详解,www.linuxidc.com我这就只说我的笔记本在左 1366x768,外接显示器在右1440x900的命令,也就是右侧扩展屏幕
6,$xrandr --output VGA1 --mode 1440x900_60.00 --right-of LVDS1
打开外接显示器(最高分辨率),设置为右侧扩展屏幕
接着,编写脚本:
#!/bin/sh
# monitor.sh
# Check whether the external monitor is connected:
# returns 0 on success
xrandr | grep VGA | grep " connected"
if [ $? -eq 0 ]; then
xrandr --newmode "1680x1050_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
#xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
xrandr --addmode VGA1 "1680x1050_60.00"
#xrandr --addmode VGA1 "1440x900_60.00"
xrandr --output VGA1 --mode 1680x1050_60.00 --right-of LVDS1
#xrandr --output VGA1 --mode "1440x900_60.00" --right-of LVDS1
else
xrandr --output VGA1 --off
fi
执行一遍。使用命令xrandr查看是否有你想设置的分辨率。如果没有,再执行一遍上述脚本。如果有:
xrandr --output VGA1 --mode 1680x1050_60.00 --same-as LVDS1
关闭笔记本显示器:
xrandr --output LVDS1 --off
这样就好了。你也可以编写一个自启动脚本,每次开机运行。
查看ubuntu版本命令: cat /etc/issue