xrandr – X Window System configuration management tool

The xrandr command is a powerful tool for managing the configuration of the X Window System. It allows users to add, remove, and modify displays, as well as change the resolution, orientation, and refresh rate of each display. This command is particularly useful for users working with multiple monitors or projectors, as it simplifies the process of configuring and managing display settings.

Overview

The xrandr command can be used to perform a wide range of tasks related to display configuration. Some common use cases include:

Displaying available displays

To see a list of available displays, simply run the xrandr command without any arguments. This will display a list of all connected displays, along with their current resolution, refresh rate, and orientation.

$ xrandr
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
DP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm
   1920x1080     60.00*+  50.00    59.94  
   1680x1050     59.95  
   1600x900      60.00  
   ...
DP-2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 521mm x 293mm
   1920x1080     60.00*+  50.00    59.94  
   1680x1050     59.95  
   1600x900      60.00  
   ...

Changing display resolution

To change the resolution of a display, use the --mode option followed by the desired resolution. For example, to set the resolution of DP-1 to 1280x720, run the following command:

$ xrandr --output DP-1 --mode 1280x720

Rotating displays

To rotate a display, use the --rotate option followed by the desired orientation. For example, to rotate DP-1 by 90 degrees clockwise, run the following command:

$ xrandr --output DP-1 --rotate right

Adding and removing displays

To add a new display, use the --newmode option followed by the desired resolution, refresh rate, and other settings. Then, use the --addmode option to add the new mode to the desired display. For example, to add a new mode with resolution 1280x720 and refresh rate 60Hz, run the following commands:

$ xrandr --newmode "1280x720_60.00" 74.50 1280 1344 1472 1664 720 723 728 748 -HSync +Vsync
$ xrandr --addmode DP-1 1280x720_60.00

To remove a display, use the --output option followed by the name of the display, and then use the --off option to turn it off. For example, to turn off DP-2, run the following command:

$ xrandr --output DP-2 --off

Options

The xrandr command supports a wide range of options, including:

Option Description
-q, --query Display current settings for all outputs
--output <name> Select an output to configure
--mode <mode> Set the resolution of the selected output
--rate <rate> Set the refresh rate of the selected output
--left-of <name> Position the selected output to the left of another output
--right-of <name> Position the selected output to the right of another output
--above <name> Position the selected output above another output
--below <name> Position the selected output below another output
--rotate <orientation> Rotate the selected output to the specified orientation
--reflect <direction> Reflect the selected output in the specified direction
--primary Set the selected output as the primary output
--auto Enable automatic configuration for the selected output
--off Turn off the selected output
--newmode <name> <mode> Add a new mode with the specified name and settings
--addmode <name> <mode> Add a mode with the specified name to the selected output

Troubleshooting tips

Some common issues that users may encounter when using the xrandr command include:

  • Display not detected: If a display is not detected by the xrandr command, try checking the physical connections between the display and the computer. If the display is connected through an adapter, try using a different adapter or connecting the display directly to the computer.
  • Resolution not supported: If a desired resolution is not supported by a display, try using the --newmode and --addmode options to add a new mode with the desired resolution and refresh rate. Note that not all displays may support all resolutions and refresh rates.
  • Display orientation incorrect: If the orientation of a display is incorrect, try using the --rotate option to rotate the display to the desired orientation. Note that some displays may not support all orientations.

Notes

  • The xrandr command is a powerful tool for managing display settings, but it can also be complex and difficult to use for beginners. Users who are not familiar with the command line interface should consider using a graphical tool or utility for managing display settings.
  • The xrandr command requires the X Window System to be running in order to function properly. If the X Window System is not running, the xrandr command will not be able to detect or configure displays.