不在底座上时自动更改分辨率

不在底座上时自动更改分辨率

我的联想 W520 上装有 Ubuntu 11.04(是的,我知道这已经是旧闻了)。在家里,我有一个带双显示器的底座。我的设置相当不错 - 一切运行得几乎完美(这就是我不愿意升级的原因......因为我对 Unity 并不是 100% 的忠实拥护者)。

无论如何,我唯一感到烦恼的是,当我在旅行时,我会使用笔记本电脑的屏幕。当我将笔记本电脑从底座上取下时,我需要手动进入 nvidia x-server 设置并将分辨率从“自动”更改为 1920x1200,否则它会认为我有两个屏幕,并且我的鼠标指针将能够远离屏幕的左侧。这不是什么大问题,但我需要这样做每一个我重新启动 x 服务器(因此如果我重新启动,或者必须终止它,等等...)

如果有一种方法可以自动检测是否有外接显示器(它似乎已经这样做了),并根据连接的显示器切换到我选择的模式,那就太好了。有什么方法可以做到这一点吗?我已发布我的 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  ([email protected])  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

答案1

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.
    # <lm_name> is name of laptop monitor
    DOCKED="`hwinfo --monitor | grep "<lm_name>" | 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 

答案2

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

相关内容