Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add system unrecognized but monitor supported resolution in X
#!/bin/bash
# First we need to get the modeline string for xrandr
# Luckily, the tool `gtf` will help you calculate it.
# e.g. `gtf <hRes> <vRes> <refreshRate>`:
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 add 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, why though!?!
# 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.
# If it doesn't apply automatically, force it with:
xrandr --output VGA1 --mode "1920x1080_60.00"
# That's it... Enjoy the new awesome high-res display!
# NOTE to make the change persistent over reboots:
# - save the script file (with the necessary changes)
# - run it at startup (search the web for "How To")
# Thanks for the feedback!
@saviobabu

This comment has been minimized.

Copy link

saviobabu commented Sep 27, 2016

When i restart my computer it goes back to normal resolution.

@mikeloveapple2

This comment has been minimized.

Copy link

mikeloveapple2 commented Jun 7, 2017

Nice Job!

@jotisa

This comment has been minimized.

Copy link

jotisa commented Apr 1, 2018

It works great on Linux Mint 18 x64

@asdf5252

This comment has been minimized.

Copy link

asdf5252 commented Jun 21, 2018

Hello debloper,

It goes to previous resolution when I restart my system, Is there any permanent solution for setting resolution so that It does not go to previous resolution ?

@TejaswiGunti

This comment has been minimized.

Copy link

TejaswiGunti commented Feb 14, 2019

Hello, I am Tejaswi Gunti..

xrandr --newmode "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
When I run the above command, it is throwing the error, " xrandr: unrecognized option '-newmode' ".. Can you please help me how to overcome the error/warning.. I connected Touch screen display to my PC via HDMI to VGA connector.. Some part of the screen(bottom) is missing i.e only 3/4th of the desktop screen is displayed on the touch screen

@frederikptk

This comment has been minimized.

Copy link

frederikptk commented May 8, 2019

Hello, I am Tejaswi Gunti..

xrandr --newmode "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
When I run the above command, it is throwing the error, " xrandr: unrecognized option '-newmode' ".. Can you please help me how to overcome the error/warning.. I connected Touch screen display to my PC via HDMI to VGA connector.. Some part of the screen(bottom) is missing i.e only 3/4th of the desktop screen is displayed on the touch screen

Well it seems like you didn't copy the line correctly. It is '--newmode' instead of '-newmode'.

@namhoangle

This comment has been minimized.

Copy link

namhoangle commented Mar 22, 2020

Hi, I got this error in the last step:

nale@r-iibi021:~$ xrandr --output xrdp_0 --mode "1920x1080_60.00"
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: 25
Current serial number in output stream: 26

I googled for a while but found no explanation. You have any ideas what they mean?

@debloper

This comment has been minimized.

Copy link
Owner Author

debloper commented Mar 23, 2020

@namhoangle from the output name, I'm guessing it's a remote desktop session. If that's the case, see if https://unix.stackexchange.com/questions/90101/xrdp-custom-resolution-fedora-19 helps.

If that's not the case, the simplest assertion would be either

  • the resolution you're trying to set isn't available for the display
  • you're using an adapter (DVI, HDMI, DP) which often causes issues
  • you're using NVIDIA drivers, which has some history of causing issues.

Without knowing more about the relevant details of the system, it'll not be possible to pinpoint the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.