From Gentoo Wiki
Jump to: navigation, search
External resources

RandR and the tool xrandr are used to manage screen resolutions, rotation and screens with multiply displays in X. With version 1.4 support for multiply graphics cards was introduced, future versions (>1.5) will also support monitors attached via USB (this will probably be merged with xorg-server 1.13 with support for DisplayLink, hotplug-displaylink).


You can install x11-apps/xrandr with the following command:

root # emerge --ask x11-apps/xrandr
This tool should automatically get installed with most window managers as they use it to manage the displays.


A common way to execute X related scripts is the use of ~/.xinitrc or ~/.xprofile. Just put the line of code for xrandr in one of these files and it will be executed on every X startup to make settings permanent.


xrandr uses the monitors EDID to identify its capabilities. Some graphic drivers like the binary Nvidia or AMD, do not support xrandr. Also faulty hardware might report wrong or bad EDIDs, in those cases it is still possible to use custom made setups by trial and error.

Screen Query

Running xrandr without any arguments will show attached monitors and its capabilities:

user $ xrandr
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192
VGA1 disconnected (normal left inverted right x axis y axis)
LVDS1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 304mm x 190mm
   1440x900       60.1*+
   1024x768       60.0
   800x600        60.3
   640x480        59.9

A list of different types for connectors and the naming scheme for RandR:

Screen Modes

A mode always consists of a resolution and a refresh-rate. With a query the hardware reports which modes are supported. It is possible to define own modes in case the hardware reports wrong information. To change the mode for an attached device:

user $ xrandr --output LVDS --mode 1024x768

It will use the highest refresh-rate in that mode, to also change the refresh-rate (in kHz):

user $ xrandr --output LVDS --mode 1024x768 --rate 75

The changes apply immediately and on the hardware listed above it might either produce an error or the screen goes blank, because 75kHz is not supported. This will last until the next session, using Ctrl+Alt+Backspace will terminate the session and restart X in case something goes wrong. To add a 75Hz mode, the tool cvt can be used to get a proper modeline:

user $ cvt 1024x768 refresh 75

Everything after Modeline needs to be appended to the following command:

user $ xrandr --newmode "1024x768_75.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

Running the query again should list our new added mode.

Adding the mode manually does not make the monitor work in the mode, if it didn't work before.

Screen Manipulation

Some common tasks using xrandr:

  • Extend to an external monitor (left-of, right-of, above, below, same-as):
user $ xrandr --output DVI-0 --auto --left-of LVDS
  • Set the primary display if more than one is attached:
user $ xrandr --output LVDS --primary
  • Rotate a display (normal, left, right, inverted):
user $ xrandr --output LVDS --rotate left
  • Turn off the monitor
user $ xrandr --output LVDS --off

GUI Tools

There are several GUI tools to use xrandr, here is a list of tools supported in Gentoo:

External Resources