Son O’ Tip O’ The Day: X rotation

If you followed yesterday’s tip o’ the day, you’ll have your console and your GNOME session rotated…but there’s still a piece of the puzzle missing! X doesn’t have rotation set, so GDM is sideways. Cue more neck twisting and mouse fumbling. Fret not, though: even this can be solved! It’s a moderately-known fact that anything you can do with xrandr, you can do statically in xorg.conf: you have to figure out the syntax, though. I find this page an invaluable crutch in figuring out post-RandR 1.2 xorg.conf syntax, though a few notes on there are a bit out of date now.

Referring to that and man xorg.conf, I came up with this for my system. xorg.conf has been modularized on Fedora and probably other distros in recent releases, so I saved it as /etc/X11/xorg.conf.d/99-screens.conf . I don’t think it counts as a full xorg.conf, so it may not work if saved as /etc/X11/xorg.conf.

Section “Device”
Identifier “nouveau”
Driver “nouveau”
Option “Monitor-DVI-I-1” “Right Monitor”
Option “Monitor-DVI-I-2” “Left Monitor”
EndSection

Section “Monitor”
Identifier “Left Monitor”
Option “Primary” “True”
Option “Rotate” “left”
EndSection

Section “Monitor”
Identifier “Right Monitor”
Option “RightOf” “Left Monitor”
Option “Rotate” “left”
EndSection

Notes on the above:

The “Identifier” lines are arbitrary – it’s just a convenient name you can use to refer to the device in question elsewhere in the config. You can make them whatever you like.

Now, for the “Device” section…

“Driver” is not arbitrary – it specifies the X driver to use for this graphics card. Obviously, enter whatever driver you actually use here. (I haven’t tested if X will auto-detect it if you leave this line out, or just throw a wobbly.)

“Right Monitor” and “Left Monitor”, in the Option lines in the Device section, reflect the names we specify for the two monitors lower down, in the “Monitor” sections’ Identifier lines. The “Monitor” sections define monitor configurations. These two Option lines tell X “use these particular monitor configurations for these two physical card outputs”.

Monitor-DVI-I-1 and Monitor-DVI-I-2 identify the specific physical card outputs on my computer. You may have to change these for yours. You can figure out what your outputs are named by just running ‘xrandr’ and looking at the output. You’ll see lines like this (depending on how many monitors you have):

DVI-I-2 connected 1080×1920+0+0 left (normal left inverted right x axis y axis) 475mm x 267mm
DVI-I-1 connected 1080×1920+1080+0 left (normal left inverted right x axis y axis) 475mm x 267mm

They tell you the names of your outputs – for me, DVI-I-1 and DVI-I-2. Prefix Monitor- to these, for use in xorg.conf. So I wind up with Monitor-DVI-I-1 and Monitor-DVI-I-2.

So, with this “Device” section, we tell X what driver to use, and to use the monitor definitions we call “Left Monitor” and “Right Monitor” for two specific physical outputs.

The two “Monitor” sections specify the actual configuration for these two monitors. As discussed above, the Identifier lines give a name to these configurations, and must match with the Option lines in the Display section.

The only Option line that’s actually necessary for rotation is:

Option “Rotate” “left”

So if all you care about is the rotation, you could just have a section like this:

Section “Monitor”
Identifier “Left Monitor”
Option “Rotate” “left”
EndSection

and it’d work fine. The extra lines in my config specify which monitor is primary (GDM will display on that monitor, and if you don’t override it within the desktop configuration, it’ll be the primary monitor for whatever desktop you’re using, so the panel will probably appear on it), and specify the layout of the monitors.

Like the numeric value for fbcon, the keyword in the Option “Rotate” lines depends on which way you rotated your monitors. Try both “left” and “right” and see which one’s correct for you.

So now the output is rotated consistently throughout startup (once fbcon module is loaded, anyway), GDM, and GNOME for me. Yay. I haven’t figured out if it’s possible to rotate the bootloader menu and/or BIOS screens yet.

One Response

  1. Links 30/6/2011: Ubuntu 11.10 Development Update, HP’s Linux (WebOS) Up For Licensing? | Techrights

    […] Son O’ Tip O’ The Day: X rotation […]

Leave a Reply

Your email address will not be published. Required fields are marked *