Revision as of 18:06, 1 March 2017

xrandr is an official configuration utility to the RandRX Window System extension. It can be used to set the size, orientation or reflection of the outputs for a screen. For configuring multiple monitors see the Multihead page.

Installation

Testing configuration

When run without any option, xrandr shows the names of different outputs available on the system (LVDS, VGA-0, etc.) and resolutions available on each, with a * after the current one and a + after the preferred one :

If you need dynamic configuration, you need to execute xrandr commands each time X server starts. See Autostarting#Graphical for details. This method has the disadvantage of occurring fairly late in the startup process, thus it will not alter the resolution of the display manager if you use one.

Custom scripts calling xrandr can be bound to events (for example when external monitor is plugged in), see acpid for details. The #Scripts section provides you with some example scripts that might be useful for this purpose.

Tip: Both KDM and GDM have startup scripts that are executed when X is initiated. For GDM, these are in /etc/gdm/, while for KDM this is done at /usr/share/config/kdm/Xsetup and for SDDM at /usr/share/sddm/scripts/Xsetup. This method requires root access and mucking around in system config files, but will take effect earlier in the startup process than using xprofile.

Scripts

Toggle external monitor

This script toggles between an external monitor (specified by $extern) and a default monitor (specified by $intern), so that only one monitor is active at a time.

The default monitor should be connected when running the script, which is always true for a laptop.

With the --force option, xrasengan will update status of all outputs before HDMI-0 is turned off, avoiding an X crash if they were the only connected/active outputs.

To force reload current settings, xrasengan provides a --try-reload-active-layout option, which uses --force and unxrandr from the arandr package to assemble the command line:

$ xrasengan --try-reload-active-layout

This can be used in systemd unit or in a keyboard binding to avoid blank screen when resuming DisplayPort monitors from suspend.

Troubleshooting

Adding undetected resolutions

Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected by xrandr. For example, the EDID data block queried from the monitor may be incorrect. However, we can add the desired resolutions to xrandr.

First we run gtf or cvt to get the Modeline for the resolution we want:

For some LCD screens (samsung 2343NW), the command "cvt -r" (= with reduced blanking) is to be used.

Note: If the Intel video driver xf86-video-intel is used, it may report the desired resolution along with its properties in /var/log/Xorg.0.log — use that first if it is different from the output of gtf or cvt. For instance, the log and its use with xrandr:

EDID checksum is invalid

Or xrandr --addmode might give you the error X Error of failed request: BadMatch. NVIDIA users should read NVIDIA/Troubleshooting#xrandr BadMatch. BadMatch could indicate an invalid EDID checksum. To verify that this is the case, run X in verbose mode (e.g. startx -- -logverbose 6) and check your Xorg log for messages about a bad EDID.

Resolution lower than expected

If you video card is recognized but the resolution is lower than you expect, you may try this.

Background: ATI X1550 based video card and two LCD monitors DELL 2408(up to 1920x1200) and Samsung 206BW(up to 1680x1050). Upon first login after installation, the resolution default to 1152x864. xrandr does not list any resolution higher than 1152x864. You may want to try editing /etc/X11/xorg.conf, add a section about virtual screen, logout, login and see if this helps. If not then read on.

About the numbers: DELL on the left and Samsung on the right. So the virtual width is of sum of both LCD width 3600=1920+1680; Height then is figured as the max of them, which is max(1200,1050)=1200. If you put one LCD above the other, use this calculation instead: (max(width1, width2), height1+height2).

Correction of overscan tv resolutions

With a flat panel TV, w:overscan looks like the picture is "zoomed in" so the edges are cut off.

Check your TV if there is a parameter to change. If not, apply an underscan and change border values.
The required underscan vborder and underscan hborder values can be different for you, just check it and change it by more or less.

Full RGB in HDMI

It may occur that the Intel driver will not configure correctly the output of the HDMI monitor. It will set a limited color range (16-235) using the Broadcast RGB property, and the black will not look black, it will be grey.