How to set a custom resolution in 16.04

This is basically the same question as How to set a custom resolution? But that one is old and never got a solution it seems. And I'm now on Kubuntu 16.04.

So I have the same problem, I tried to add a new resolution using xrandr, this is what I did:

cvt 1920 1080 60
Output:
# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync

xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync

xrandr --addmode DP-4 "1920x1080_60.00"
Output:
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  18 (RRAddOutputMode)
  Serial number of failed request:  41
  Current serial number in output stream:  42

And this is the output from "xrandr":

xrandr
Screen 0: minimum 8 x 8, current 3840 x 2160, maximum 16384 x 16384
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 346mm x 194mm    3840x2160     60.00*+
DP-5 disconnected (normal left inverted right x axis y axis)
DP-6 disconnected (normal left inverted right x axis y axis)
1920x1080_60.00 (0x260) 173.000MHz -HSync +VSync
    h: width  1920 start 2048 end 2248 total 2576 skew    0 clock  67.16KHz
    v: height 1080 start 1083 end 1088 total 1120           clock  59.96Hz

I'm on a Lenovo p50 laptop, having disabled the intel VGA card and using only the Nvidia card, using Nvidia drivers.


The problem is (I think) is that you don't have sufficient permissions. If you are a sudoer, just run it again, except with sudo:

You need a "modeline", and then tell it to xrandr To set your modeline, use cvt:

$ sudo cvt width height refreshrate

Example:

$ sudo cvt 1680 1050 60

Note: It probably isn't necessary to run sudo on cvt.

This gives you:

# 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

Provide this to xrandr (example):

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

You will then add it to the possible resolutions:

$ sudo xrandr --addmode VGA-0 1680x1050_60.00

I hope this answers your question.