Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu 11.04 (yep, I know it's old news) on my Lenovo W520. At home, I have a dock with dual monitors. I have a pretty decent setup - things work almost perfectly (hence the reason I'm reluctant to upgrade... that and I'm not 100% sold on Unity).

Anyway, the only annoyance I have is that when I'm on travel, I use the laptop screen. When I un-dock the laptop, I need to manually go into nvidia x-server settings and change the resolution from 'Auto' to 1920x1200, or it will think I have two screens, and my mouse pointer will be able to go way off the left side of the screen. This isn't a big deal, but I need to do it every time I restart the x-server (so if I reboot, or have to kill it, etc...)

What would be really nice is if there was a way for it to automatically detect whether or not there is external monitors (which it seems to do already), and switch into the mode I select, depending on which monitors are connected. Is there any way to accomplish this? I've posted my xorg.conf file for reference.

# 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
share|improve this question
    
I recommend to use the opensource drivers with an ubuntu 12.04, for these reasons: xorg.conf is depricated since 10.04? or so. Nobody uses that anymore (except for nvidia proprietary drivers) nvidia drivers are security risks, they are really bad noveau (os alternative driver) should support the Quadro 1000M fully and therefore xrand will, so no need to fiddle around with nVidia Settings crap. Nobody would ever waste lifetime in xorg.confs, since 2005 (except idiots)!! I give 100 bounty on top if anybody will! –  mondjunge Oct 22 '12 at 16:33
    
What do you mean by 'opensource' drivers? Sorry, I'm having difficulty understanding your response... –  jwir3 Oct 22 '12 at 21:58
    
There are open source drivers for nVidia cards, they arre called nouveau and installed by default (though not acrtive if your run the proprietary ones). while searching for a Hardware compatibility list I found this blog entry (zachstechnotes.blogspot.de/2012/04/post-title.html) exactly for the W520. I think in the end you should dist-upgrade and try to use bumblebee to get most of your Laptop. Btw. there is no problem in ditching Unity and using Shell or anything else in 12.04, its just a matter of install, logging off and on again. –  mondjunge Oct 23 '12 at 7:53

2 Answers 2

up vote 1 down vote accepted
+100

Install hwinfo if you don't already have it.

Now, run $hwinfo --monitor or just $hwinfo

DO NOT connect it to the dock now. Reboot, choose your favourite resolution and run

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

DOCK the system now, and reboot. Choose your new favourite resolution and run

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

Make a script file and add it to autorun:

    # 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 
share|improve this answer
    
It looks like this will work, but I'm testing it now. I'm trying to make the deadline for the bounty. If it works, I'll award it to you. –  jwir3 Oct 24 '12 at 17:20
    
How can I set this to 'autorun'? –  jwir3 Oct 24 '12 at 17:27
    
Copy the script (as dock-undock.sh) to /etc/init.d Make it executable by running $ sudo chmod +x /etc/init.d/dock-undock.sh. Make it run at startup $ sudo update-rc.d dock-undock.sh. Open 'Startup Applications` in Unity Launcher (press super key) and make a new entry with the path to this script file given using 'browse' option. Happy docking! :-) –  TomKat Oct 24 '12 at 17:35
    
If the commands don't work as stated, make required changes in the script as per your system. –  TomKat Oct 24 '12 at 17:38
    
I feel like this would work, but the hwinfo command isn't returning anything for either the docked or undocked state. (It won't detect the Lenovo LCD monitor). Any suggestions on how I might be able to get it to recognize either the dell monitor I have connected to the dock, or the lcd monitor? –  jwir3 Oct 24 '12 at 20:15

There are some tools to automate the switching between monitors. you can use this tools, to automate it RandR, disper, displex or this one http://gnomefiles.org/content/show.php/Laptop+external+display+hotplugging?content=138742

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.