Howto Force Display Resolution -- XRANDR

Share your own howto's etc. Not for support questions!

Howto Force Display Resolution -- XRANDR

Postby rhss62011 » 2012-04-13 15:19

Hello there,
I used to have a Laptop and after upgrading it in Linux the screen resolution wouldn't work anymore the way I wanted it (1200x800). After some research I found out how to more or less force the system to use the resolution I wanted, so here goes:

First of all -- use your terminal. Any terminal will do...

USERNAME:~$ xrandr
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 1600 x 1600
DFP1 disconnected (normal left inverted right x axis y axis)
DFP2 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
1280x1024 60.0*+ 75.0
1280x960 60.0 + 75.0
1280x800 60.0 + 75.0
1152x864 60.0 + 75.0
1280x768 59.9 + 74.9
1280x720 60.0 +
1152x648 60.0 +
1024x768 75.0 70.1 60.0
800x600 72.2 75.0 70.0 60.3
720x480 60.0
640x480 75.0 72.8 60.0
CRT1 disconnected (normal left inverted right x axis y axis)
CRT2 disconnected (normal left inverted right x axis y axis)
TV disconnected (normal left inverted right x axis y axis)

Typing the command xrandr will tell you what you display is - in my case it's recognized as DFP2

Now Let's pretend you want a resolution of 1368x768

USERNAME:~$ cvt 1360 768 60
# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz
Modeline "1360x768_60.00" 84.75 1360 1432 1568 1776 768 771 781 798 -hsync +vsync

Using the command cvt 1360 768 60 makes the terminal tell you what line you'll be adding to xrandr for a resolution of 1360 x 768 with a refresh rate of 60.
NOTICE: You will want to copy the "1360x768_60.00" 84.75 1360 1432 1568 1776 768 771 781 798 -hsync +vsync into a text file or something as you will need it later...

Now comes the fun part - telling xrandr to add the new mode to your display, and to use it:


USERNAME:~$ xrandr --newmode "1360x768_60.00" 84.75 1360 1432 1568 1776 768 771 781 798 -hsync +vsync

This adds the mode to xrandr and nothing else so we have to add it to your display configurations in order to use it:

USERNAME:~$ xrandr --addmode DFP2 "1360x768_60.00"

NOTICE: The output of DFP2 is my personal monitor - you will have to replace that with your own!!!
Also notice, that there are no errors - if you have an error you'll have to change the resolution to something your system will recognize as a proper resolution format - I will add such formats at the bottom of this thread

Now we need to force the monitor to use the desired resolution:

USERNAME:~$ xrandr --output DFP2 --mode "1360x768_60.00"

Now that your screen is using the resolution you want, we have one more step -- creating a start-up script. The next steps will:
1. Create a folder in your home directory in which we will place your personal script
2. We will use a text editor to create the script to change your resolution
3. From the script inside the folder we will tell Linux to automatically execute the script when you log in.

In the terminal:

NOTICE: This will open up your text editor (Gedit in this case) with a new file called ""
Now just copy and paste the following text, or edit it as needed for your preferences

#Edit the text file as you need it for your personal computer or use as is if you want the same resolution:
xrandr --newmode "1360x768_60.00" 84.75 1360 1432 1568 1776 768 771 781 798 -hsync +vsync && xrandr --addmode DFP2 "1360x768_60.00" && xrandr --output DFP2 --mode "1360x768_60.00"
#Notice that you need to change the output DFP2 to whatever XRANDR recognizes as your display!!!

Now that we have the script we need to make it executable:

USERNAME:~$ cd /home/YOUR-USER-NAME/START-SCRIPTS ; sudo chmod +x

Now, just go to your settings ---> Session and Startup ---> Application Autostart
And add the script just like you would any other application...

Edited to add this:

esolution - Aspect ratio













User avatar
Posts: 7
Joined: 2011-06-07 22:19

Re: Howto Force Display Resolution -- XRANDR

Postby vallee » 2012-11-11 16:09

hello, where to find out what my monitor name is ??
Last edited by vallee on 2012-11-12 11:45, edited 1 time in total.
Posts: 8
Joined: 2012-11-11 16:07

Re: Howto Force Display Resolution -- XRANDR

Postby phenest » 2012-11-11 17:10

Code: Select all
apt-get install x11-xserver-utils

It wasn't installed on my system.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D
User avatar
Posts: 1704
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Howto Force Display Resolution -- XRANDR

Postby jrussell88 » 2013-01-04 19:20

I'm running Ubuntu 12.04 x64, kernel 3.2.0-24-generic with an NVidia GTX460 and an Achieva Shimian QH270-Lite 2560 x 1440 monitor connected by a dual-link DVI cable.

I've installed the nvidia-current 313-09 drivers from xorg-edgers (and tried the 310-19 from NVidia). Neither of these drivers read the EDID information from my monitor (/var/log/Xorg.0.log) and default to lower resolutions which my monitor will not display, resulting in a black screen. Full story here

If I replace the high-res monitor with a lower resolution 1600 x 900 monitor it works fine.

I want to force my video card to the resolution I need. NVidia's Xserver settings doesn't change anything. The xorg.conf configuration file is deprecated and the file is untouched by 12.04, so I tried xrandr with similar results to cement_head.

First I queried the Modeline for my resolution:


john@Vivid01:~$ cvt 2560 1440 60
# 2560x1440 59.96 Hz (CVT 3.69M9) hsync: 89.52 kHz; pclk: 312.25 MHz
Modeline "2560x1440_60.00" 312.25 2560 2752 3024 3488 1440 1443 1448 1493 -hsync +vsync

Then set up a new mode for it:


john@Vivid01:~$ xrandr --newmode "2560x1600_60.00" 348.50 2560 2760 3032 3504 1600 1603 1609 1658 -hsync +vsync

And attempted to attach it to a display - with a similar error:


john@Vivid01:~$ xrandr --addmode DVI-I-1 "2560x1440_60.00"
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 153 (RANDR)
Minor opcode of failed request: 18 (RRAddOutputMode)
Serial number of failed request: 31
Current serial number in output stream: 32

Perhaps xrandr doesn't allow complete customisation - or maybe it is built on code which is no longer relevant?

Does anyone know how to get this to work for Ubuntu 12.04 and recent NVidia drivers?
Posts: 1
Joined: 2013-01-04 18:23

Re: Howto Force Display Resolution -- XRANDR

Postby dasein » 2013-01-04 19:45

jrussell88 wrote:I'm running Ubuntu 12.04 x64...
Does anyone know how to get this to work for Ubuntu 12.04...?

I'm sure someone does. But at the risk of overstating the incredibly obvious, your question is better directed here:
User avatar
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Howto Force Display Resolution -- XRANDR

Postby DominiqueM » 2013-09-01 21:14

An alternative is to use FVWM-Crystal. It have a resolution submenu in its main menu, which use xrandr and let the user to change the screen resolution on the fly. It doesn't support custom resolutions yet, only the ones provided by xrandr.

This menu show the current resolution as first line, and all the possible choices at the following lines.
Posts: 40
Joined: 2013-08-30 10:08

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 5 guests