Tips for XRandR

(or: Help, why doesn't my projector work under Linux?)

This is just a few things the manpage doesn't explain very well (especially when you're in a hurry).

Running xrandr on its own will show the outputs you have (this is the --query option which is default).

$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1920x1080      60.0*+   40.0
   1400x1050      60.0
   1280x1024      60.0
   1280x960       60.0
   1024x768       60.0
   800x600        60.3     56.2
   640x480        59.9
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

This is my laptop without any external screen connected (in my case eDP1 is the name of the internal displayport for the LCD screen). The * denotes the active mode.

Turn on an output:

$ xrandr --output HDMI1 --auto

Mirror the output from the internal screen:

$ xrandr --output HDMI1 --auto --same-as eDP1

The left of the screen isn't visible:

$ xrandr --output HDMI1 --transform 1,0,-100,0,1,0,0,0,1 (This moves the screen 100px to the right, without any scaling, which can be useful to fix projectors with weird setups.)

The top of the screen isn't visible:

$ xrandr --output HDMI1 --transform 1,0,0,0,1,-100,0,0,1 (This moves the screen 100px down, without any scaling, you can combine this with the above command.)

Scale the output

$ xrandr --output HDMI1 --scale 1.2x1.2

(This is useful when your slides or such turn out to need a different resolution to the one you should use. This may not look very good but will at least make your slides visible.)

Turn off transforms

$ xrandr --output HDMI1 --transform none

Turn off an output:

$ xrandr --output HDMI1 --off

Harder things

If you want to combine scaling with transforms things are harder. The manpage is not very helpful at explaining the transform matrix. Using --verbose will show the transform matrix in use.
$ xrandr --verbose
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (0x47) normal (normal left inverted right x axis y axis) 344mm x 193mm
[...]
  Transform:  1.000000 0.000000 0.000000
              0.000000 1.000000 0.000000
              0.000000 0.000000 1.000000
[...]
If we use the example from above of moving the display in from the left, we see a different transform matrix in the verbose output:

  Transform:  1.000000 0.000000 -100.000000
              0.000000 1.000000 0.000000
              0.000000 0.000000 1.000000
             filter: bilinear
We can also look at the matrix for scaling up to 1.2:

  Transform:  1.199997 0.000000 0.000000
              0.000000 1.199997 0.000000
              0.000000 0.000000 1.000000
             filter: bilinear
With this information can then combine both the transforms into a transform command by simply adding commas: $ xrandr --output HDMI1 --transform 1.2,0,-100,0,1.2,0,0,0,1

Links