Thinkpad 笔记本上配置Fn+F7设置多显示器切换功能

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 11"> <meta name="Originator" content="Microsoft Word 11"> <link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CLIUJIX%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"> <smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="chmetcnv" downloadurl=""></smarttagtype><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object> <style> st1/:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} pre {margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:760294477; mso-list-type:hybrid; mso-list-template-ids:1897017604 67698707 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-number-format:chinese-counting-thousand; mso-level-text:%1、; mso-level-tab-stop:49.0pt; mso-level-number-position:left; margin-left:49.0pt; text-indent:-21.0pt;} @list l1 {mso-list-id:1896114535; mso-list-type:hybrid; mso-list-template-ids:929467402 -1621743200 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-tab-stop:73.75pt; mso-level-number-position:left; margin-left:73.75pt; text-indent:-45.75pt;} @list l1:level2 {mso-level-number-format:alpha-lower; mso-level-text:"%2/)"; mso-level-tab-stop:70.0pt; mso-level-number-position:left; margin-left:70.0pt; text-indent:-21.0pt;} @list l2 {mso-list-id:2091535319; mso-list-type:hybrid; mso-list-template-ids:1744616176 894186144 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l2:level1 {mso-level-tab-stop:46.0pt; mso-level-number-position:left; margin-left:46.0pt; text-indent:-18.0pt;} @list l2:level2 {mso-level-number-format:alpha-lower; mso-level-text:"%2/)"; mso-level-tab-stop:70.0pt; mso-level-number-position:left; margin-left:70.0pt; text-indent:-21.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

目前,随着Linux操作系统hal的探测和适配功能的不断强大,Thinkpad笔记本还是IBM笔记本的许多快捷键都可以很方便,很快捷的直接使用,但是,也有部分功能键需要用户自己去手工的设置一下,这也许就是Linux不太完善的原因吧。还需要大家不断的完善呀!

Linux系统下,多显示输出的问题,不用多想,这肯定是与显卡驱动有很大的关系的,这的确是如此的,多显示输出的确是与显卡驱动有关系的。目前从Linux系统下使用的显卡驱动来说,大致上有两种显卡驱动模式,一种是官方驱动,这种驱动是有显卡芯片制造公司提供的,这种驱动的优点在于显卡驱动能够充分发挥显卡的性能,并且使用起来比较稳定。但是也有不少弊端,第一,驱动内容虽然老是在更新,但是都只是为了支持新出的产品,已经很久没有更新实质性的内容了,所以社区的许多新特性在这些驱动上无法使用。拿NVIDIA驱动来说,该驱动虽然能够与大部分机器充分适合,但是该驱动把所有的显示器都当作是CRT显示器处理了,所以在一些液晶显示器上,我们会看到“超出显示范围”这样的字样,很麻烦【不过这个问题是可以解决的】。再拿ATI的官方驱动来说,该驱动目前还不支持Fedora 9Fedora 10这些最新的社区版本。这对部分喜欢Fedora的人来说,的确是件麻烦事,希望FedoraATI的朋友们能够尽快改进这个问题。第二,对显示器的输出考虑的不周全,也正是因为这个原因,导致所有使用官方驱动的显卡都无法使用下面的第二种设置方法。因此使用官方驱动时多显示器输出的设置方法还需要大家帮忙琢磨一下。

第二种显卡驱动就是Linux社区提供的驱动,常见的是X.org提供的。这种显卡驱动虽然不能够全面的发挥显卡的性能,但是能够很好的与社区融合,与底层的图形系统很好的摩擦在一起。而且这种驱动对多显示输出的支持比较好。

好了言归正传,下面开始介绍Thinkpad笔记本上多显示输出的适配方法。

<!--[if !supportLists]-->一、 <!--[endif]-->简单方法:

这个方法虽然很简单,但是用于与快捷键的直接绑定,还是有点麻烦。不过这对应不常用的用户来说,还是比较快捷的。那么是怎么样的呢?

<!--[if !supportLists]-->1. <!--[endif]-->使用grandr工具来设置。

Grandr工具是一个图形化的工具,当你接入两个或者多个显示器以后,打开grandr工具,在其中就可以看到你所接的所有显示器,只要在里面将要输出的显示器制定即可。很方便;

<!--[if !supportLists]-->2. <!--[endif]-->使用xrandr工具来设置。

Xrandr工具是Xorg自带的一个字符工具,这个工具不仅能够在当前的显示下设置多分辨率的设置,而且还能够实现多个显示器的自动切换。具体的设置步骤如下:

<!--[if !supportLists]-->a) <!--[endif]-->执行xrandr –q命令来查看当前接入的显示器情况。如果你有多个显示器的话,你不仅能够看到你接入的显示器,而且还能够看到各个显示器下能够支持到的分辨率。

注意:xrandr的输出信息中,各个显示器显示的不是显示器的名称,而是显示的是他们的接口名称。当然如果是这样的接口有多个,则会以数字来做区分的。不过一般的笔记本也就带一到三个不同的接口而已。

<!--[if !supportLists]-->b) <!--[endif]-->执行xrandr –output VGA –auto来输出到自己想输出的显示器上。

其中VGALVDSS-video都是显示器接口类型,这要根据实际情况来定。其中—auto是指根据显示器与显卡驱动共同能够支持的分辨率,选择一个最佳分辨率输出。而这个最佳分辨率一般是以显示器的BIOS值为准。因为目前常用的分辨率,显卡驱动都能够支持到。

如果有多个显示器同时要输出,只需要在xrandr后面多个几个—output 显示器接口 –auto就可以了。

如果对输出到显示器上的分辨率不满意的话,还可以制定一个特定的分辨率,不过要注意的是,要输出分辨率必须是在xrandr –q中该显示器下能够支持到的分辨率。该参数就是—mode。具体的命令是:xrandr –output VGA –mode 1024x768

要关闭在某个显示器上的输出,可以采用 –off参数来关闭。具体的命令是xrandr –output VGA –off

Xrandr的常用参数介绍:

-q: 查询当前能够切换的显示器已经分辨率的支持情况;

-s 分辨率: 切换到一个指定的分辨率下。这只适合单个显示器的情况;

--output 接口名称: 指定要处理的显示器。这需要结合具体的操作来进行;

--auto: 自动选择一个最佳分辨率输出到该显示器上;

--mode 分辨率: 根据指定的分辨率输出;

--off: 关闭在该显示器上的输出。

<!--[if !supportLists]-->二、 <!--[endif]-->好的设置方法:

这个方法是针对那种想一次性绑定到快捷键上,以后常用的。具体的设置步骤如下:

<!--[if !supportLists]-->1. <!--[endif]-->设置acpi

创建一个新文件/etc/acpi/events/thinkpad.conf,内容是:

event=ibm/hotkey HKEY 00000080 00001007

action=/usr/local/sbin/thinkpad-fn-f7

如果是ubuntu系统,请修改文件/etc/acpi/events/ibm-videobtn的内容为:

# /etc/acpi/events/ibm-videobtn

# This is called when the user presses the video button. It is currently

# a placeholder.

event=ibm/hotkey HKEY 00000080 00001007

action=/bin/true

创建文件/etc/acpi/resume.d/91-ibm-hotkey-enable.sh,在其中输入:

#!/bin/bash

# enable ibm-hotkeys (specifically Fn2, Fn7)

# 12 bit mask, little end is F1 default 0x<chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="80" unitname="C" w:st="on">080c</chmetcnv> = F12+F4+F3

echo enable,0x084e > /proc/acpi/ibm/hotkey

这里的主要工作是,将Fn+F7快捷键绑定在acpi中。

<!--[if !supportLists]-->2. <!--[endif]-->创建/usr/local/sbin/thinkpad-fn-f7脚本:

#!/bin/bash

# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
EXTERNAL_OUTPUT="VGA"
INTERNAL_OUTPUT="LVDS"
EXTERNAL_LOCATION="left"

# Figure out which user and X11 display to work on
# TODO there has to be a better way to do this?
X_USER=$(w -h -s | grep ":[0-9]/W" | head -1 | awk '{print $1}')
export DISPLAY=$(w -h -s | grep ":[0-9]/W" | head -1 | awk '{print $3}')

# Switch to X user if necessary
if [ "$X_USER" != "$USER" ]; then
SU="su $X_USER -c"
else
SU="sh -c"
fi

case "$EXTERNAL_LOCATION" in
left|LEFT)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
right|RIGHT)
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
;;
top|TOP|above|ABOVE)
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
;;
bottom|BOTTOM|below|BELOW)
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
;;
*)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
esac

# Figure out current state
INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep " con" | sed "s/.*connected//" | sed "s/ //" | sed "s/ .*//g")
EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep " con" | sed "s/.*connected//" | sed "s/ //" | sed "s/ .*//g")

if [ -z "$INTERNAL_STATE" -o $INTERNAL_STATE = "(normal" ]; then
STATE="external"
elif [ -z "$EXTERNAL_STATE" -o $EXTERNAL_STATE = "(normal" ]; then
STATE="internal"
else
INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then
STATE="both"
else
STATE="mirror"
fi
fi

if [ -f /tmp/switch -a $STATE != "internal" ]; then
STATE="mirror"
fi
function screen_external(){
$SU "xrandr --output $INTERNAL_OUTPUT --off"
$SU "xrandr --output $EXTERNAL_OUTPUT --auto"
rm -f /tmp/switch
}

function screen_internal(){
$SU "xrandr --output $EXTERNAL_OUTPUT --off"
$SU "xrandr --output $INTERNAL_OUTPUT --auto"
touch /tmp/switch
}

function screen_mirror(){
$SU "xrandr --output $INTERNAL_OUTPUT --auto"
$SU "xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT"
}

function screen_both(){
$SU "xrandr --output $INTERNAL_OUTPUT --auto"
$SU "xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION"
}

function screen_toggle(){
case "$STATE" in
internal)
screen_mirror
;;
mirror)
screen_external
;;
external)
screen_both
;;
both)
screen_internal
;;
*)
screen_internal
;;
esac
}

# What should we do?
DO="$1"
if [ -z "$DO" ]; then
if [ $(basename $0) = "thinkpad-fn-f7" ]; then
DO="toggle"
fi
fi

case "$DO" in
toggle)
screen_toggle
;;
internal)
screen_internal
;;
external)
screen_external
;;
mirror)
screen_mirror
;;
both)
screen_both
;;
status)
echo "Current Fn-F7 state is: $STATE"
echo
echo "Attached monitors:"
$SU xrandr | grep "/Wconnected" | sed "s/^/ /"
;;
*)
echo "usage: $0 <command>" >&2
echo >&2
echo " commands:" >&2
echo " status" >&2
echo " internal" >&2
echo " external" >&2
echo " mirror" >&2
echo " both" >&2
echo " toggle" >&2
echo >&2
;;
esac


set permissions and restart acpi

<!--[if !supportLists]-->3. <!--[endif]-->修改脚本权限:

修改脚本的权限为可执行,具体命令是:sudo chmod 755 /usr/local/sbin/thinkpad-fn-f7

重启acpi服务,具体命令是:sudo service acpid restart

<!--[if !supportLists]-->三、 <!--[endif]-->参考文献:

http://www.thinkwiki.org/wiki/Sample_Fn-F7_script

http://www.thinkwiki.org/wiki/Install_Ubuntu_8.10_(Intrepid_Ibex)_on_a_Thinkpad_T400

http://www.thinkwiki.org/wiki/ThinkWiki

http://www.thinkwiki.org/wiki/How_to_get_special_keys_to_work

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值