95

I'm a new Linux user trying to change the screen resolution as there is no option under display. I have successfully managed to add new resolutions by fluke by following online guide. I don't have a GPU, I don't know if this is the issue? Below is my xrandr -q output.

root@kali:~# xrandr -q
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 1280 x 1024, current 1280 x 1024, maximum 1280 x 1024
default connected 1280x1024+0+0 0mm x 0mm
   1280x1024       0.0* 
  1920x1200_60.00 (0x145)  193.2MHz
        h: width  1920 start 2056 end 2256 total 2592 skew    0 clock   74.6KHz
        v: height 1200 start 1203 end 1209 total 1245           clock   59.9Hz
  1440x900_59.90 (0x156)  106.3MHz
        h: width  1440 start 1520 end 1672 total 1904 skew    0 clock   55.8KHz
        v: height  900 start  901 end  904 total  932           clock   59.9Hz
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
nick
  • 961

7 Answers7

123

Here are the steps you need to add a new custom resolution and apply it. Following steps are for adding a 1920x1080 resolution, but you can use it for any other resolution you want. But make sure your monitor and onboard graphics support that resolution.

# First we need to get the modeline string for xrandr
# Luckily, the tool "gtf" will help you calculate it.
# All you have to do is to pass the resolution & the-
# refresh-rate as the command parameters:
gtf 1920 1080 60

In this case, the horizontal resolution is 1920px the

vertical resolution is 1080px & refresh-rate is 60Hz.

IMPORTANT: BE SURE THE MONITOR SUPPORTS THE RESOLUTION

Typically, it outputs a line starting with "Modeline"

e.g. "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync

Copy this entire string (except for the starting "Modeline")

Now, use "xrandr" to make the system recognize a new

display mode. Pass the copied string as the parameter

to the --newmode option:

xrandr --newmode "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync

Well, the string within the quotes is the nick/alias

of the display mode - you can as well pass something

as "MyAwesomeHDResolution". But, careful! :-|

Then all you have to do is to add the new mode to the

display you want to apply, like this:

xrandr --addmode VGA1 "1920x1080_60.00"

VGA1 is the display name, it might differ for you.

Run "xrandr" without any parameters to be sure.

The last parameter is the mode-alias/name which

you've set in the previous command (--newmode)

It should add the new mode to the display & apply it.

Usually unlikely, but if it doesn't apply automatically

then force it with this command:

xrandr --output VGA1 --mode "1920x1080_60.00"

Original source: https://gist.github.com/debloper/2793261

I also wrote a script that does all these steps automatically. You can try it out if the above steps seem too complicated for you: https://gist.github.com/chirag64/7853413

  • If you have some part of your second display shown on the first display after fallowing the answer above, you should re-arrange display layout from displays settings. Reason is in xrandr the number after plus sign is not refreshed after changing res from 960 to 1920: eg: 2560x1080+960+0 to 2560x1080+1920+0 – Oncel Umut TURER Jan 16 '19 at 11:53
  • In case you receive xrandr: cannot find output "VGA1", check your output devices with: xrandr --listmonitors (source: https://unix.stackexchange.com/a/413304/106621) – Antônio Medeiros Jan 16 '20 at 11:17
  • 7
    X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 139 (RANDR) Minor opcode of failed request: 7 (RRSetScreenSize) Serial number of failed request: 22 Current serial number in output stream: 23 What the hell does that mean? – undefined Apr 23 '20 at 22:03
  • 5
    Instead of gtf one may use cvt, e.g. cvt 1920 1080, which produces the same output as gtf, but it calculates also valid refresh rate. (Giving refresh rate to gtf by hand may not always give supported output values). – Cromax May 12 '20 at 23:07
  • It helped me with VirtualBox 6.1, which forces me to use the VMSVGA graphics controller, but set the screen size to 800x600. – apaderno Aug 12 '20 at 07:48
  • If gtf is not available (as it was in my docker container), you could use an online modeline calculator. – Dave Gööck Oct 29 '20 at 14:58
  • Is there a rule for which resolutions are allowed? I tried to use a horizontal resolution of 683 (half the resolution of 1366) but it automatically converted this to 680. – Aaron Franke Dec 28 '20 at 08:06
  • I wanted pixel-perfect 4K for my Sony TV (3840x2160). I knew that rez was possible as I had assigned my VM enough display memory for xrandr to show even higher rez (4096x2160). These instructions worked flawlessly, thanks. – moodboom Feb 17 '21 at 21:26
  • xrandr --output command gives error xrandr: Configure crtc 1 failed – Alex Dec 01 '23 at 07:51
32

The option --size/-s can be used:

xrandr -s 1440x900

Should work with RandR version 1.1 or newer.

jimmij
  • 47,140
  • 3
    When i do this the response is : size 1440x900 not found in available modes – nick Sep 06 '15 at 15:22
  • @nick From the output which you included in the question I deduced it should be available. What's the output of xrandr --verbose? – jimmij Sep 06 '15 at 15:26
  • xrandr: Failed to get size of gamma for output default Screen 0: minimum 1024 x 768, current 1024 x 768, maximum 1024 x 768 default connected 1024x768+0+0 (0x138) normal (normal) 0mm x 0mm Identifier: 0x137 Timestamp: 5048 Subpixel: unknown Clones:
    CRTC: 0 CRTCs: 0 Transform: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 filter:
    – nick Sep 06 '15 at 15:35
  • 1024x768 (0x138) 0.0MHz *current h: width 1024 start 0 end 0 total 1024 skew 0 clock 0.0KHz v: height 768 start 0 end 0 total 768 clock 0.0Hz – nick Sep 06 '15 at 15:35
  • So it seems the only available resolution is 1024x768. Is this resolution what you want to set? – jimmij Sep 06 '15 at 15:41
  • no I would like to option to change is, but so far all my attempts have been fairly unsuccessful and when I restart my efforts ended up being in vain – nick Sep 06 '15 at 15:44
  • @nick what resolution do you want? You wrote in question that you have add some resolution - which one and how? Edit the question, describe the problem properly with all details. – jimmij Sep 06 '15 at 15:48
  • In general though this is the correct answer. – Owl Jun 29 '18 at 11:02
10

I had the same problem. In Display setting maximum resolution was 1280x720. So:

  1. using xrandr command I have seen name of this monitor and resolution list.
  2. I 've executed the script: xrandr --output {name of monitor} --mode {resolution}

For example:

xrandr --output DP-2-1 --mode 2560x1440
grep
  • 239
6

This is what I had to do on an #IntelMaker #Joule in order to make it work in the native resolution with a SUNFOUNDER 7 INCH TFT COLOR MONITOR, which is listed as having 1024*600 resolution, but was picked up as 1280x720 instead.

First, Intel Joule with Linux 4.4.15-yocto-standard x86_64 doesn't seem to have gtf(1), so, I had to use a different machine to calculate the appropriate numbers:

$ gtf 1024 600 60

  # 1024x600 @ 60.00 Hz (GTF) hsync: 37.32 kHz; pclk: 48.96 MHz
  Modeline "1024x600_60.00"  48.96  1024 1064 1168 1312  600 601 604 622  -HSync +Vsync

$ 

Then, create a file with the appropriate commands:

# cat > 1024x600.sh
xrandr --newmode "1024x600_60.00"  48.96  1024 1064 1168 1312  600 601 604 622  -HSync +Vsync
xrandr --addmode HDMI1 "1024x600_60.00"
xrandr --output HDMI1 --mode "1024x600_60.00"
^D
# chmod +x 1024x600.sh

Then, startx or startxfce4, and run ./1024x600.sh, after which, the following will be reported by xrandr(1).

# xrandr
Screen 0: minimum 8 x 8, current 1024 x 600, maximum 32767 x 32767
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 697mm x 392mm
   1280x720      60.00 +  50.00    59.94  
   1920x1080     60.00    50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1280x1024     75.02  
   1440x900      74.98    59.90  
   1024x768      75.08    70.07    60.00  
   1024x600      60.00  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x576i      50.00  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       75.00    72.81    60.00    59.94  
   720x400       70.08  
   1024x600_60.00  60.00* 
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
# 
cnst
  • 3,283
  • Answer includes irrelevant personal user and host names, and doesn't clearly separate commands from their output - all of which can be confusing to the readers. A standard method of conveying that something is a command would be prefixing it simply with $. Kali's default WM is also GNOME, not XFCE, maybe it should be made clear that startxfce4 command is only for users running XFCE version 4. The likelihood that many other users will be running exactly Linux 4.4.15-yocto-standard x86_64 doesn't seem high to me, so I'd instead write that gtf (or cvt) might have to be installed first. – miyalys May 21 '18 at 10:57
  • @miyalis aside for the unnecessary mention of the distro the rest of the solution is fine. The command you are talking about were to be pasted inside a script and they should not be prefixed by$. In this regard your comment is wrong , all the commends are prefixed with #, which is the equivalent prompt for the root user. – Bogdan Apr 15 '22 at 23:27
4

Save the script and launch it (bash script.sh 1024 720 60) you can set the custom resolution with that script but it is a temporary solution whenever you logout and login again you have to run the script again .you can add 2 lines of code in your bash.bashrc profile.to run the script directly from terminal.

#!/bin/bash
# xrandr.sh
#If no argument is specified, ask for it and exit
if [[ -z "$@" ]];
then
echo "An argument is needed to run this script";
exit
else
arg="$@"
#Basic check to make sure argument number is valid. If not, display error and exit
if [[ $(($(echo $arg | grep -o "\s" | wc --chars) / 2 )) -ne 2 ]];
then
echo "Invalid Parameters. You need to specify parameters in the format "width height refreshRate""
echo "For example setResolution "2560 1440 60""
exit
fi

#Save stuff in variables and then use xrandr with those variables
modename=$(echo $arg | sed 's/\s/_/g')
display=$(xrandr | grep -Po '.+(?=\sconnected)')
if [[ "$(xrandr|grep $modename)" = "" ]];
then
xrandr --newmode $modename $(gtf $(echo $arg) | grep -oP '(?<="\s\s).+') &&
xrandr --addmode $display $modename
fi
xrandr --output $display --mode $modename

#If no error occurred, display success message
if [[ $? -eq 0 ]];
then
echo "Display changed successfully to $arg"
fi
fi
Newbie
  • 57
4

I ran:

xrandr --verbose

which gave me a list of size tags and corresponding pixel values

then I used

xrandr -s 6

to select the 1920x1080 resolution

2

My problem is the notebook resolution have this:

Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 ...
   1366x768      60.00*+  47.98  <=== MaxResolution (Default/Primary)
   1360x768      59.80    59.96  
   1280x720      60.00 ...

My primary/default screen is 1366x768.

But I would like to test a resolution 1920x1080 (DesireResolution) in my notebook.

I tried everything.

I couldn' t find a solution because my notebook don't accept addmode or newmode commands from xrandr to increase resolution, like this stackexchange question request.

So I did some maths!

1920/1366 = 1.4055636896
1080/768 = 1.40625

basically DesireResolution/MaxResolution

and run this command

xrandr --output eDP1 --mode 1366x768 --panning 1920x1080 --scale 1.40556369x1.40625

If you need restore original resolution

xrandr --output eDP1 --mode 1366x768 --panning 1366x768 --scale 1x1

You can adapt to any resolution you want.

macm
  • 121