I'm building a utility that simplifies the complexities of defining and adding/removing custom resolutions with cvt and xrandr down to at least 2 command inputs.
The idea is to enter a custom resolution and frame rate (similar to how you'd do with cvt) on a specific port if using multiple, and see if your monitor on said port can display it.
The 2nd command is a simple y or n entry if your screen isn't black.
here's where the trick comes in, and the problem I'm running into...
If you enter n
on the validation prompt, the screen should be reset to the previous resolution, which also includes the current resolution upon startup.
The problem I'm facing is it doesn't seem possible to obtain the current modeline upon startup of the utility.
Does anyone know of a way to obtain the EXACT modeline for xrandr --output ##### --mode <mode>
or is that not a possibility??
This is a quite old question, but in case anyone stumbles over the problem, here is the answer. From the command line the simplest way is using
The corresponding modeline can be extracted from the numbers in the output, e.g.
In case you need to fix the modeline you can also manually add that modeline via xrandr.
In case you are writing a program you might of course want to use libXrandr, especially its
XRRGetOutputInfo
function to read the desired information from the mode'sXRRModeInfo
struct.