The RandR (Resize and Rotate) X protocol extension and its CLI 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).
The x11-apps/xrandr package can be installed with the following command:
emerge --ask x11-apps/xrandr
This tool should automatically install with most window managers since it is used to manage the displays.
There are several GUI tools to use xrandr. Here is a list of tools supported in Gentoo:
- x11-misc/arandr – Another XRandR GUI (an independent GUI tool)
- lxde-base/lxrandr – LXDE GUI interface to RandR extension
A common way to execute X related scripts is the use of ~/.xinitrc or ~/.xprofile files in a user's home directory. 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 Extended Display Identification Data (EDID) to identify its capabilities. Faulty hardware might report wrong or bad EDIDs, in those cases it is still possible to use custom made setups by trial and error.
Running xrandr without any arguments will list all available display output interfaces and display devices along with their current state and capabilities:
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192 VGA-1 disconnected (normal left inverted right x axis y axis) LVDS-1 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 xrandr query result contains all available interfaces labeled as
<interface_name>-<index>. Each shows its connection status and the reported screen modes. The connected device's current mode is hinted by
*, the preferred mode is hinted by
The RandR naming scheme for common display interfaces:
LVDS- Laptop screen
HDMI- High-Definition Multimedia Interface
DVI- Digital Visual Interface
VGA- Video Graphics Array
TV- Composite Video
It is possible to manipulate output interfaces discovered via a xrandr query. Examples of common tasks:
- Set the primary display if more than one device is attached:
xrandr --output LVDS-1 --primary
- Extend to an external display attached on a known interface (left-of, right-of, above, below, same-as):
xrandr --output DVI-1 --auto --left-of LVDS-1
- Rotate a display (normal, left, right, inverted):
xrandr --output LVDS-1 --rotate left
- Turn off the device:
xrandr --output LVDS-1 --off
A mode always consists of a resolution and a refresh-rate. With a xrandr 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:
xrandr --output LVDS-1 --mode 1024x768
It will use the highest refresh-rate in that mode, to also change the refresh-rate (in kHz):
xrandr --output LVDS-1 --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 (x11-base/xorg-server) can be used to get a proper modeline:
cvt 1024x768 refresh 75
Everything after Modeline needs to be appended to the following command:
xrandr --newmode "1024x768_75.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
Running the query again should list the newly added mode.
Adding the mode manually does not make the display device work in the mode if it did not work before.
- Xorg — an open source implementation of the X Window System.