Ezequiel Mastrasso

View Original

xrandr, nvidia prime & cvt – how to add custom screen resolution

When using nvidia-prime, the nvidia panel settings are disabled, xrandr obscures the card settings from Xorg.
See the http://ezequielm.com/blog/rhelcentos-7-3-nvidia-prime-setup/ for more info on xrandr and nvidia prime.

xrandr -q

This command will list all your devices and modes.
In my case on a razer blade with a 4k screen i do not have a full HD option. I only get a native res, or a list of other resolutions that weirdly enough do not contain a 1920 1080

First run:

cvt 1920 1080

This command yields the modeline below

1920x1080 60.00 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz Modeline "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync

we can add the modeline to the resolution to the list

sudo xrandr --newmode "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync

This will add the new mode to the xrandr.

Now we add the mode to the monitor, in my case is eDP-1-1

sudo xrandr --addmode eDP-1-1 "1920x1080_60.00"

finally, we set the resolution with the command

$ xrandr --output eDP-1-1 --mode 1920x1080_60.00

Boila!

you can always add the last 3 commands into a textfile called changeResToFullHD.sh, set it as executable and run it when you please as ./changeResToFullHD.sh from the command line