Linux Programming

xrandr – Display tool on Linux

xrandr
xrandr

xrandr is a command-line tool that enables users to configure and manage displays in Linux and Unix-based operating systems. It is a powerful tool that provides a wide range of features, including setting up multiple displays, adjusting screen resolution and orientation, adjusting brightness and gamma, and advanced features like rotation and flipping.

To better understand how to use xrandr, let’s take a look at some examples:

Example 1: Setting up Multiple Displays with xrandr

One of the most common uses of xrandr is setting up multiple displays. For instance, let’s say we have two monitors, and we want to set up our second monitor to extend the desktop of the first one. We can use the following command:

xrandr --output VGA-1 --auto --right-of LVDS-1

In this example, VGA-1 represents our second monitor, and LVDS-1 represents our primary monitor. The --auto option enables the monitor to use its native resolution automatically. The --right-of option specifies that we want the second monitor to be positioned to the right of the primary monitor.

Example 2: Adjusting Screen Resolution

xrandr can also be used to adjust the screen resolution. Let’s say we want to change the resolution of our primary monitor to 1920×1080. We can use the following command:

xrandr --output LVDS-1 --mode 1920x1080

In this example, LVDS-1 represents our primary monitor, and --mode specifies the resolution we want to use.

Example 3: Adjusting Screen Brightness and Gamma

xrandr can also adjust the screen brightness and gamma. Let’s say we want to reduce the brightness of our primary monitor by 50%. We can use the following command:

xrandr --output LVDS-1 --brightness 0.5

In this example, LVDS-1 represents our primary monitor, and --brightness specifies the brightness level we want to use.

Example 4: Advanced Features – Rotating the Screen

xrandr also supports advanced features like rotating the screen. Let’s say we want to rotate our primary monitor by 90 degrees. We can use the following command:

xrandr --output LVDS-1 --rotate left

In this example, LVDS-1 represents our primary monitor, and --reflect specifies the axis we want to flip the screen on. The options available are normal, x, y, and xy.

Overall, xrandr is a powerful tool that can be used to configure and manage displays in Linux and Unix-based operating systems. The examples above provide just a small sample of what is possible with this tool. With xrandr, users can easily set up multiple displays, adjust screen resolution and orientation, adjust brightness and gamma, and perform advanced features like rotation and flipping.

While xrandr can seem intimidating at first, with a bit of practice, it can become an essential tool for anyone working with

Tags

About the author

Ajay Verma

A Computer Science Graduate, who works extensively on open source projects. His Areas Of interest are: Network Security, Linux Administration, FOSS, Python, and C programming.

Add Comment

Click here to post a comment