Software & AppsOperating SystemLinux

How To Set a Custom Resolution with xrandr on Ubuntu

Ubuntu 9

In this article, we will guide you through the process of setting a custom resolution with xrandr on Ubuntu. The X Resize, Rotate and Reflect Extension (xrandr) is a utility in the X Window System that allows you to resize, rotate, and reflect the root window of a screen. This can be particularly useful when the default resolutions provided by your system do not meet your requirements.

Quick Answer

To set a custom resolution with xrandr on Ubuntu, you need to generate a modeline using the cvt command, add the new mode to xrandr with the --newmode option, apply the new resolution with the --addmode option, and make the changes permanent by creating a ~/.xprofile file.

Understanding xrandr

Before we dive into the process, it’s important to understand what xrandr is. xrandr is a command-line tool for managing your monitor’s resolution and refresh rate. It’s a part of the X.Org server, which is the default display server for most Linux distributions, including Ubuntu.

Checking Available Resolutions

The first step is to check the available resolutions for your monitor. You can do this by simply typing xrandr into your terminal. This command will display the current settings and all the available resolutions for your monitor.

Generating a Modeline

To set a custom resolution, we first need to generate a “modeline”. A modeline is a configuration line in the X server configuration file that provides information to the server about a connected display. You can generate a modeline using the cvt command. The syntax is cvt width height refreshrate. For example, to generate a modeline for a resolution of 1680×1050 at 60Hz, you would run:

cvt 1680 1050 60

The output will look something like this:

# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync

Adding the New Mode to xrandr

After generating the modeline, we need to add it to xrandr. This is done with the --newmode option. Run the following command, replacing the modeline values with the ones from the previous step:

xrandr --newmode "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync

Applying the New Resolution

Next, we need to apply the new resolution. This is done with the --addmode option. Replace VGA-0 with the appropriate output identifier (you can find this by running xrandr without any options):

xrandr --addmode VGA-0 1680x1050_60.00

Making the Changes Permanent

If you want the resolution to persist after reboot, you need to create the file ~/.xprofile with the following content:

#!/bin/sh
xrandr --newmode "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA-0 1680x1050_60.00

Remember to replace VGA-0 with the correct output identifier.

Conclusion

In this article, we have covered how to set a custom resolution with xrandr on Ubuntu. We hope this guide has been helpful. If you encounter any issues or have any questions, feel free to leave a comment below.

What is xrandr?

xrandr is a command-line tool in the X Window System that allows you to manage your monitor’s resolution and refresh rate.

How can I check the available resolutions for my monitor?

You can check the available resolutions for your monitor by typing xrandr into your terminal. This command will display the current settings and all the available resolutions.

How do I generate a modeline?

To generate a modeline, you can use the cvt command followed by the desired width, height, and refresh rate. For example, cvt 1680 1050 60 will generate a modeline for a resolution of 1680×1050 at 60Hz.

How do I add the new mode to xrandr?

After generating the modeline, you can add it to xrandr using the --newmode option. For example, xrandr --newmode "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync.

How do I apply the new resolution?

To apply the new resolution, you can use the --addmode option followed by the output identifier and the new resolution. For example, xrandr --addmode VGA-0 1680x1050_60.00.

How can I make the changes permanent?

To make the resolution changes permanent, you can create the file ~/.xprofile and add the xrandr commands for the new mode. Remember to replace VGA-0 with the correct output identifier.

Can I use xrandr on other Linux distributions?

Yes, xrandr is a part of the X.Org server, which is the default display server for most Linux distributions. Therefore, you can use xrandr on other Linux distributions as well, not just Ubuntu.

What should I do if I encounter any issues or have questions?

If you encounter any issues or have any questions, feel free to leave a comment below the article. We will be happy to assist you.

Leave a Comment

Your email address will not be published. Required fields are marked *