Customizing screen resolutions with xrandr

Screen Makeover

Article from Issue 251/2021
Author(s):

You can boost productivity on an old laptop using xrandr to quickly and easily gain some extra screen real estate.

If you are anything like me, you may have an old laptop from the mid-2010s lying around that still works well but has some obvious deficiencies. While the hardware is mostly fine, the 15.6-inch screen has bezels that encroach well into where we now expect to see uninterrupted screen space. With a few modifications, this old laptop is a perfect candidate for a backup Linux machine for when your main laptop inevitably fails (even if you do need to carry the charger with you at all times). After buying a pair of 4GB DDR3 sticks and the least expensive 120GB SSD you can find and installing Ubuntu, this old laptop runs great, but the screen still feels like something from the Windows ME days. All you need is a few simple terminal commands using xrandr on Ubuntu [1] to bring the 1366x768-resolution screen up to something a bit more reasonable, greatly improving your overall experience.

There are a few caveats, however. One is that bumping up the resolution will likely cause text to appear fuzzy and less crisp. This is something that most users can become accustomed to in time. It won't look pretty, but at least you will be able to have more than one document or program window open at the same time. Another caveat is that you will likely experience, at the very least, some tearing when moving windows around – nothing that will affect performance in any meaningful way, as long as you don't need high graphic fidelity. Lastly, and obviously, you should probably avoid using this laptop for any video or image production because having an accurate representation on your screen is paramount for those kinds of tasks. With these caveats in mind, let's break down the process.

Custom Resolution

First you need to determine the base X Window System [2] configuration to which your custom resolution will be added. To do this, open a terminal window and run:

$ xrandr

For reference later, write down which display output is being used. This will be something like HDMI-#, DP-#, LVDS-#, or VGA-# (where the # is typically a   or 1). The first section indicates the connection technology, and the digit indicates the monitor number. This will be important to know later. For example, Figure 1 shows the output from xrandr for the Dell E6430 14-inch laptop, circa 2012, that I used to write this article.

Figure 1: The xrandr command output.

Next, determine your monitor's characteristics at your selected resolution. You will want to continue to use the same aspect ratio (width to height) when scaling to a higher resolution. For instance, a 1366x768 monitor that is 14 inches or larger can typically accommodate any 16:9 resolution up to 2560x1440 while still offering fairly legible text. To determine the characteristics needed, run the following command:

$ cvt <desired width in pixels> <desired length in pixels>

Running this cvt command on my Dell for a desired resolution of 1920x1080 results in the information shown in Figure 2.

Figure 2: The cvt command output.

The modeline listed in the cvt command's output shown in Figure 2 should also be noted because that, too, will be used later. At this point, use the xrandr --newmode command to add the desired mode to the configuration. Copy and paste the modeline information after xrandr --newmode so that the correct timings and resolution will be used (Figure 3).

Figure 3: The newmode command.

Finally, use the xrandr --addmode command followed by the desired resolution and frequency (Figure 4), which will then be accessible in the Gnome Display Settings panel in the Gnome Control Center (Figure 5).

Figure 4: The addmode command.
Figure 5: Your desired resolution now shows up in the Gnome Display Settings panel.

Persistence

Now you can open the Gnome Control Center and choose the desired resolution. You can then see how good (or bad) the new resolution looks on your particular machine. However, there is one problem at this point: When you sign out or reboot, your custom resolution will no longer be in the Gnome Control Center, forcing you to re-enter these commands in the terminal to access the resolution each time you sign in.

There is a simple workaround for this problem: Add the newmode and addmode commands to the end of the .profile file in your /home/user directory (Figure 6). I prefer to simply open Home, view hidden files by using Ctrl+H, open the .profile file with gedit, copy and paste those two commands at the very bottom, and save. Pressing Ctrl+H again will hide the hidden files once more and resume the default view. Now the resolution change will survive reboots and logout/login for the user whose .profile was amended. Purists may want to use Vim or nano, but to each his or her own. If you're feeling indecisive, you can always run

gedit /home/<user>/.profile
Figure 6: The .profile configuration file with custom resolution commands added.

from the terminal and add the two needed lines that way.

Conclusion

With a few simple commands in the terminal, you can use xrandr to customize the resolution on older machines, breathing new life into old hardware.

The Author

Adam Dix is a mechanical engineer and Linux enthusiast posing as an English teacher after playing around a bit in sales and marketing. You can check out some of his Linux work at the EdUBudgie Linux website (https://www.edubudgie.com).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • acpid Hot Keys

    A little research from the command line and a short script bends your keyboard to your will.

  • Multi-heading with RandR

    The RandR X server extension gives users more intuitive control over video projectors and multi-head installations.

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • Introduction

    This month in Linux Voice.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News