不在停靠时自动更改分辨率

我的联想W520上有Ubuntu 11.04(是的,我知道这是旧闻)。 在家里,我有一个带双显示器的底座。 我有一个相当不错的设置 – 事情几乎完美的工作(因此我不愿意升级…那我并没有100%在Unity上销售)。

无论如何,我唯一的烦恼是,当我在旅行时,我使用笔记本电脑的屏幕。 当我取消对接笔记本电脑时,我需要手动进入nvidia x-server设置并将分辨率从“自动”更改为1920×1200,否则它会认为我有两个屏幕,我的鼠标指针将能够关闭屏幕的左侧。 这不是什么大问题,但每次重启x-server 需要这样做(所以如果我重新启动,或者必须杀死它等等)

真正好的是,如果有一种方法可以自动检测是否有外部监视器(它似乎已经存在),并切换到我选择的模式,具体取决于连接的监视器。 有没有办法实现这个目标? 我发布了我的xorg.conf文件以供参考。

# nvidia-settings: X configuration file generated by nvidia-settings # nvidia-settings: version 270.29 (buildd@allspice) Fri Feb 25 14:42:07 UTC 2011 # nvidia-xconfig: X configuration file generated by nvidia-xconfig # nvidia-xconfig: version 275.19 (buildmeister@swio-display-x86-rhel47-07.nvidia.com) Tue Jul 12 18:35:38 PDT 2011 #Section "Monitor" # Identifier "Monitor1" # VendorName "Lenovo" # ModelName "ThinkpadLCD" # #HorizSync 28.0 - 33.0 # #VertRefresh 43.0 - 72.0 # #Option "DPMS" #EndSection Section "ServerLayout" Identifier "Layout0" Screen 0 "Screen0" 0 0 InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Mouse0" "CorePointer" Option "Xinerama" "0" EndSection Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/psaux" Option "Emulate3Buttons" "no" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" # generated from default Identifier "Keyboard0" Driver "kbd" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Unknown" ModelName "DELL U2410" HorizSync 30.0 - 81.0 VertRefresh 56.0 - 76.0 Option "DPMS" EndSection Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "Quadro 1000M" Option "RegistryDwords" "EnableBrightnessControl=1" EndSection Section "Screen" # Removed Option "metamodes" "DFP-0: nvidia-auto-select +0+120, DFP-6: nvidia-auto-select +1920+0" # Removed Option "metamodes" "DFP-0: nvidia-auto-select +0+120, DFP-5: nvidia-auto-select +1920+0" # Removed Option "metamodes" "DFP-0: nvidia-auto-select +1920+419, DFP-5: nvidia-auto-select +3840+0, DFP-6: nvidia-auto-select +0+0" # Removed Option "metamodes" "DFP-5: nvidia-auto-select +0+0, DFP-6: 1920x1200 +1920+0" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 Option "NoLogo" "True" Option "TwinViewXineramaInfoOrder" "DFP-0" Option "TwinView" "1" Option "metamodes" "DFP-5: nvidia-auto-select +1920+0, DFP-6: 1920x1200 +0+0" SubSection "Display" Depth 24 EndSubSection EndSection 

如果您还没有安装hwinfo ,请安装它。

现在,运行$hwinfo --monitor$hwinfo

现在不要将它连接到底座。 重新启动,选择您喜欢的分辨率并运行

 $ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.undock 

立即关闭系统,然后重新启动。 选择您最喜欢的新分辨率并运行

 $ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.dock 

制作一个脚本文件并将其添加到自动运行:

  # Check if system is docked or undocked and use correct xorg.conf file. #  is name of laptop monitor DOCKED="`hwinfo --monitor | grep "" | wc -l`" # Next line is for debugging # echo $DOCKED > /root/docked-state.txt if [[ $DOCKED = "0" ]] then cp /etc/X11/xorg.dock /etc/X11/xorg.conf else cp /etc/X11/xorg.undock /etc/X11/xorg.conf fi # End of dock-undock script 

有一些工具可以自动切换显示器。 你可以使用这个工具来自动化它RandR,disper,displex或者这个http://gnomefiles.org/content/show.php/Laptop+external+display+hotplugging?content=138742