Jacob's solution works but there are some additional alternatives. You could put the xrandr
commands in your .xsessionrc
file, so that they're executed at startup. You could also just write an xorg.conf
entry to set your monitors explicitly left/right of each other. I'm not at my PC so I'm regrettably short on details at the moment, but will come back to fill them in later if I get time. In the meantime it would be worthwhile for you to read up on both xrandr
and xorg.conf
files in general; you might discover a better solution than what I end up putting here anyway. ^_^
EDIT: OK I'm finally getting around to this.
Using xrandr
and ~/.xsessionrc
The xrandr
utility is used to both get and set information about your displays. Type xrandr
by itself on the command line and you'll get a listing of all your displays and the "modes" that they support. Here is some example output corresponding to an old Dell 4:3 LCD.
DP2 connected 1280x1024+1920+0 (normal left inverted right x axis y axis) 338mm x 270mm
1280x1024 60.0*+ 75.0
1152x864 75.0
1024x768 75.1 60.0
800x600 75.0 60.3
640x480 75.0 60.0
720x400 70.1
You would add modes to these if your monitor's resolution isn't right, etc., but your problem is about positioning. xrandr
provides simple parameters --left-of <output>
and --right-of <output>
that allow you to dictate where your displays sit in relation to each other.
So let's say your displays identify as FOO1
and FOO2
. (They never will; this is just an example.) If you want FOO1
to be always on the left of FOO2
, you would enter:
xrandr --output FOO1 --left-of FOO2
or
xrandr --output FOO2 --right-of FOO1
Typing this on the command line will immediately make the change for your current session. Inserting the same line into your ~/.xsessionrc
file will make the change effective every time you start X.
Using xorg.conf
Your other alternative is to write an xorg.conf
entry that will dictate display configuration as part of the X startup process. If you're on Ubuntu then this will likely be part of a file in an xorg.conf.d
directory, either at /usr/share/X11/xorg.conf.d
or /etc/X11/xorg.conf.d
. So if you don't already have one, create a config file to drive your display adapters and monitors. I called mine 01-monitors.conf
to ensure it got executed first. Reusing the previous example with FOO1
being to the left of FOO2
, we can set up the same preference here with a Monitor
config section.
Section "Monitor"
Identifier "FOO1"
Option "LeftOf" "FOO2"
EndSection
Note that the Identifier
is the same one you'd get from xrandr
.
Further Reading
The man
page for the xorg.conf
configuration system is available at http://www.x.org/archive/X11R7.7/doc/man/man5/xorg.conf.5.xhtml