Just about every desktop environment comes with some way to configure and control your monitors, but some aren’t quite up to par, and bugs can be a factor. Then, there are tiling window managers and more minimal desktops that don’t have those utilities. In any of these cases, Xrandr, the Xorg’s own utility for monitor management is your best friend, and it’s not too hard to use.

In this tutorial you will learn:
  • How to Find Info About Your Monitors
  • How to Set Your Monitor Resolution
  • How to Set Your Monitor Refresh Rate
  • How to Manage Dual Monitor Setups
Configure Monitors With Xrandr
Configure Monitors With Xrandr.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Nearly All Linux Distros
Software Xrandr
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to Find Info About Your Monitors



Before you do anything, you’re going to need to find out a bit about your monitors, like how your system is referencing them, their available resolutions, and their refresh rates. You can accomplish all of this with a simple command to query your monitors.

$ xrandr -q
Xrandr Monitor Info
Xrandr Monitor Info.

The results might look complex, but they’re really simple, once you break them down. Each heading is actually a listing for one of the ports on your graphics card. They’ll be something like DisplayPort-0 or DVI-D-0. Next to each one, you’ll see if it’s connected or disconnected. The connected ones are obviously the monitors that you have in use.

Next to that connection status, you’ll see whether that monitor is the primary. After that you’ll see a notation the current resolution of your monitor with position information, denoted by the plus signs. The first position is the x coordinate, and the second is the y. The primary monitor will have zeroes in these positions. A secondary monitor placed to the right, like in the image, will have +1920 or something similar in the x position.

The available resolutions are listed down the left side of what amounts to a table under each connected display. To the left of each resolution, you’ll find the available refresh rates for that resolution listed out going from left to right. There’s an asterisk(*) next to the refresh rate that your monitor is currently set at.

How to Set Your Monitor Resolution



Now that you have a general idea what your monitors are capable of, you can set the resolution of one. Take a look at the available resolutions. Then, use Xrandr to set it.

$ xrandr --output DVI-D-0 --mode 1920x1080

The --output flag is necessary to specify which monitor you’re targeting. Then the --mode flag tells it which resolution to use.

How to Set Your Monitor Refresh Rate

The --rate flag allows you to set your monitor’s refresh rate. Take a look at your monitor’s information. Select a rate that your monitor can use at its current resolution. Then, use the flag to set your monitor’s refresh rate.

$ xrandr --output DVI-D-0 --mode 1920x1080 --rate 60.00

How to Manage Dual Monitor Setups

The situation is similar for dual monitor set ups. Just specify the information for both monitors in your command. It should look something like this:

$ xrandr --output DisplayPort-0 --mode 1920x1080 --rate 144.00 --output DVI-D-0 --mode 1920x1080 --rate 60.00

Dual monitor set ups have some added flags that can be useful for positioning and priority. The --primary flag specifies the primary monitor. You can use the --left-of and --right-of flags to set the position of your other monitors. All together, it looks something like the example below.

$ xrandr --output DisplayPort-0 --primary --mode 1920x1080 --rate 144.00 --output DVI-D-0 --mode 1920x1080 --rate 60.00 --right-of DisplayPort-0

Conclusion

Xinitrc With Xrandr
Xinitrc With Xrandr.

You’re now ready to manage your monitors and provide specific detail straight to the X Server. It’s important to note that Xrandr is highly scriptable, and you can run it as a startup script. You can also include Xrandr statements in your .xinitrc file or run it as a script in your window manager’s startup.

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME or create a JOB ALERT on LinuxCareers.com job portal.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions