How to add custom screen resolution in Ubuntu

xrandr

Within of the most common problems that I encountered when I first migrate to Ubuntu was the topic of screen resolutions and a few additional hardware detection issues, I'm talking about 10 years ago, I had a gaming rig back then.

For this I used 3 monitors and used the ports of the graphics card and additional to it with the port of the motherboard, which in Windows is possible more without on the other hand in Linux I have not been able to do it.

Anyway it is not something that requires for it as many of you will know, all possible resolutions are emulated in Windows while on Linux only the right ones so to speak so when I wanted to make mirror screens I ran into a big problem, since when using the VGA ports it only displayed certain resolutions while with DVI and HDMI other things that I generate conflict.

For this I found Xrandr a small tool that helped me solve my problems. In this case we must have all the monitors that we are going to use or if it is only one we have no problem.

In the first step we are going to enable one more resolution to our monitor settings, first we verify the option we want to have with our monitor and our graphics card, in my case I am interested in enabling 1280 × 1024 resolution.

Now it is important to check what resolutions our monitor can support as well as what frequency it works on.

Already investigated this, with this data we obtain them with this syntax:

gtf 1280 1024 70

This command line threw me something like the following:

# 1280×1024 @ 70.00 Hz (GTF) hsync: 63.00 kHz; pclk: 96.77 MHz
Modeline “1280x1024_70.00” 96.77 1152 1224 1344 1536 864 865 868 900 -HSync +Vsync

What interests us is the following:

96.77 1152 1224 1344 1536 864 865 868 900 -HSync +Vsync

Before it alone we must execute the following in terminal:

Xrandr

Where we will show information about our monitors, here we will identify them, in my case I have VGA-0 DVI-1 and HDMI-1

After getting the data to add to the screen modes we proceed to add these modes as follows, adding what the previous command gave us:

xrandr --newmode “1280x1024_70.00″ 96.77 1152 1224 1344 1536 864 865
868 900 -HSync +Vsync

After executing this previous line, which added the new resolution mode of our Screen, we execute the following command line, I will add the resolution to the HDMI and DVI monitors:

xrandr --addmode DVI-1 1280x1024_70.00

xrandr --addmode HDMI-1 1280x1024_70.00

And finally we proceed to enable the resolutions

xrandr --output DVI-1 --mode 1280x1024_70.0

xrandr --output HDMI-1 --mode 1280x1024_70.0

With this last command line we have enabled the resolution mode that we want in our Ubuntu and we can choose it from System> Preferences> Monitors or we can enable it simply by executing this command line (in my case):

xrandr -s 1280x1024_70.0

Finally I can only comment that This process is only valid during our session that we have so when restarting the system the applied changes are not saved, to solve this problem we can create a script that runs at startup.

Or we can make use of the following, we open the following file and edit:

sudo gedit /etc/gdm/Init/Default 

We will look for the following lines:

PATH=/usr/bin:$PATH
OLD_IFS=$IFS 

And just below them, in my case I add the following:

xrandr --newmode “1280x1024_70.00″ 96.77 1152 1224 1344 1536 864 865
868 900 -HSync +Vsync

xrandr --addmode DVI-1 1280x1024_70.00

xrandr --addmode HDMI-1 1280x1024_70.00

xrandr --output DVI-1 --mode 1280x1024_70.0

xrandr --output HDMI-1 --mode 1280x1024_70.0

Another is to create a bash that executes the same commands, but in my case I stick with the above.

#!/bin/bash
# setting up new mode
xrandr --newmode “1280x1024_70.00″ 96.77 1152 1224 1344 1536 864 865
868 900 -HSync +Vsync
xrandr --addmode DVI-1 1280x1024_70.00
xrandr --addmode HDMI-1 1280x1024_70.00
xrandr --output DVI-1 --mode 1280x1024_70.0
xrandr --output HDMI-1 --mode 1280x1024_70.0
##sleep 1s
##done

I am not an expert creating bash, but it would be something like that, if anyone wants to support to perfect it they would be appreciated.

As far as possible, it remains for me a solution that over time has not ceased to be effective, if you know of any other method or application, do not hesitate to share it as I will be very grateful to you.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Daniel said

    Very interesting, I will keep your article in mind. Greetings.

  2.   Jose said

    I have followed your instructions, but in Ubuntu 16.04 there is no / etc / gdm directory
    I don't know where to put the script so that it starts without error.

  3.   Consulto said

    Thank you very much for the tutorial !!

    In case it can help someone ... in my case to leave the change permanently with ubuntu 18.04 I had to create a .xprofile file in home / user and add the config as follows

    sudo gedit /home/team/.xprofile

    and within the file the following, in my case with the resolution I wanted

    xrandr –newmode «1680x1050_60.00» 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync + vsync
    xrandr --addmode VGA-1 1680x1050_60.00
    xrandr --output VGA-1 --mode 1680x1050_60.00

  4.   FAM3RX said

    Brother, I thought your article was very good, it helped me a lot, thank you very much Brother!
    Take the first method, in a resolution of 1440 × 900, and it works.

  5.   Ricardo Bascuñan said

    #! / Bin / bash

    ##Usedmode:
    # Name script file modeline
    # ./modeline.sh «3840 2160 60 ″ DP-1
    #3840 2160 is the resolution
    #60ishz
    #DP-1 is the output port

    modeline = »$ (gtf $ 1 | sed -n 3p | sed 's / ^. \ {11 \} //')»
    echo $ modeline
    xrandr –newmode $ modeline
    mode = »$ (gtf $ 1 | sed -n 3p | cut -c 12- | cut -d '»' -f2) »
    xrandr –addmode $ 2 \ »$ mode \»
    xrandr –output $ 2 –mode \ »$ mode \»

  6.   Yago said

    Hello! What if I want to add that new resolution to my VGA monitor? you only made them for DVI and HDMI! Please!

    1.    David naranjo said

      You only replace the command that I put by the name that yours has, VGA-1, VGA-0, VGA-2, etc. Since you run gtf it shows you what name your monitors have.

  7.   Catome said

    Very good your article but it took all the pvto day to change the resolution. The resolution is not saved, so far fine, but neither of the two options you gave to save it works. Linux is very good, but these details make people return to windows without thinking