I have a Dell Precision M4300 with a Dell Dock PRO1X running Ubuntu Natty.
When I have the laptop docked the lcd display is off and I use two external monitors however when I undock the laptop it does not switch to the laptop screen. The same happens when I dock the laptop, it does not switch to the external monitors.
If I reboot the laptop it will choose the correct setup but it will not automatically change monitors with Ubuntu running.
My Xorg.conf
Best Answer
Dock/UnDock Scripts
I have finally put together a complete script setup that will detect my dock status and switch the monitors automatically.
The first thing I did was to get rid of my Xorg.conf as it caused more issues that it solved. Since I am using an nvdia card I eventually found that using disper was the best way to go. I had discounted it before as its standard commands could not achieve my dualview setup but then I found I could create a custom metamode to use with disper.
To create the custom metamode I used the values stored in Xorg.conf along with previous testing with nv-control-dpy and xrandr as a guide. This metamode and other twinview values were added to a file that can be passed to disper through stdin.
Due to having different sized monitors with Twinview I need to use XCreateMouseVoid, as described in this question.
Below is a complete breakdown of the scripts and files with their contents.
Scripts
Create XCreateMouseVoid script:
Script Name:
~/.mousevoid
chmod +x ~/.mousevoid
Create Disper settings file:
File Name:
~/.disperDocked
Create the export dbus session script:
Script Name:
~/.export_x_info
Set to user executable only:
chmod 700 ~/.export_x_info
Then put it in Startup Applications:
Unless you restart you need to run ~/.export_x_info to create the .Xdbus file
Create the udev rule that will run with upon a dock event:
Script Name:
/etc/udev/rules.d/81-dell-dock.rules
KERNEL=="dock.0", ACTION=="change", RUN+="/usr/local/sbin/dell-dock"
chmod +x /etc/udev/rules.d/81-dell-dock.rules
Create the script that is associated with the udev rule:
Script Name:
/usr/local/sbin/dell-dock
chmod +x /usr/local/sbin/dell-dock
Create the undock script (change your_user to match your user name):
Script Name:
/usr/local/sbin/undock
chmod +x /usr/local/sbin/undock
Create the dock script (change your_user to match your user name):
Script Name:
/usr/local/sbin/dock
chmod +x /usr/local/sbin/dock
Debug
To debug the dock scripts you have to enable udev debug logging:
Then open syslog in Log File Viewer
Resources
nVidia Readme: Config Twinview, X Config Options
Autorandr
Disper PPA
nv-control-dpy
Ubuntu Forum - Un/Dock Scripts
Thinkwiki
udevadm