Simple dual monitor setup with XrandR in Ubuntu (Linux)
Posted on: Jun-23-2008 07:03:16 PM by Stevan Ljuljdurovic
- Categories:
- Linux
- Ubuntu
- Dual Monitors
- Multiple monitor support
- XRandR
First you need to figure out the resolution of both your monitors. In my case I have a 22" monitor with a 1680x1050 resolution and my laptop monitor with a 1200x800 resolution.
Now that we have both of our monitors we need to figure out how we our displays set up. You can have it set up so your external monitor (in my case the 22" monitor) is left-of | right-of | above | below | same-as your default monitor. Note: same-as just clones your default monitor
Now its just time for some simple math. We are going to need to set a virtual resolution, so depending on how you want your monitors set up, you need to set your virtual resolution accordingly. For me, I have my 22" above my laptop monitor so I use the above option. I need total width of 1680px and a total height of 1050+800=1850px. So my virtual resolution would be 1680 1850. If I were to put my 22" monitor to the left of my laptop monitor my resolution would be a width of 1680+1280=2960 and a height of 1050, making a total virtual resolution of 2960 1050. Note: Virtual screen is limited to 2048x2048 for intel
Now that we have our resolution we need to add just one line to our xorg file. Before doing this please please make a backup, I take no responsibility if anything breaks.
To backup: sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
Add the virtual line to your xorg under the screen section, here is what mine looks like:
Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Modes "1680x1050" "1280x800"
Virtual 1680 1850
EndSubSection
EndSection
Now plug in your external monitor and restart X (alt+ctrl+backspace). We are ready to get you dual monitor layout working. For me I open up a terminal and type:
xrandr --output LVDS --mode 1280x800 --output VGA --mode 1680x1050 --above LVDS
Note: I actually just have a script that runs that command, all you have to do is make a simple bash script, and make it executable. Here is how:
Create a file on your desktop called dualscreen, or whatever you want.
Now simply add:
#!/bin/bash
xrandr --output LVDS --mode 1280x800 --output VGA --mode 1680x1050 --above LVDS
Now make the file executable: sudo chmod +x dualscreen . There you have it, click the script everytime you plug in your external monitor and you should have dualscreen working!
Now you need to modify that line based on your settings, here is the default line.
xrandr --output <output> --rate <rate> --mode <mode> --left-of|--right-of|--above|--below|--same-as <output>
Here is a list of the output names depending on what video card you are using and what type of monitor you have:
Intel
Output names:
* LVDS: internal laptop panel
* TMDS-1: external DVI port
* VGA: external VGA port
* TV: external TV output
ATI
Output names:
* LVDS: internal laptop panel
* DVI-0: first external DVI port
* DVI-1: second external DVI port (if present)
* VGA-0: first external VGA port
* VGA-1: second external VGA port (if present)
* S-video
Nvidia
Output names:
* LVDS: internal laptop panel
* DVI0: first external DVI port
* DVI1: second external DVI port (if present)
For a more in depth explanation with more examples please see this tutorial