How do you find the current "modeline" xrandr is using for an output?

Solution 1:

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

> xrandr --verbose
[...]
DP-3 connected 1920x1080+0+0 (0x22d) normal (normal left inverted right x axis y axis) 641mm x 401mm
  1920x1080 (0x22d) 148.500MHz +HSync +VSync *current +preferred
    h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
    v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
[...]

The corresponding modeline can be extracted from the numbers in the output, e.g.

Modeline "1920x1080_60"  148.5  1920 2008 2052 2200  1080 1084 1089 1125  +HSync -Vsync

In case you need to fix the modeline you can also manually add that modeline via xrandr.

> xrandr -d :1 --newmode "1920x1080_60" 148.5 1920 2008 2052 2200 1080 1084 1089 1125 +HSync -VSync
> xrandr --addmode DP-3 "1920x1080_60"      
> xrandr --output DP-3 --mode "1920x1080_60"

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's XRRModeInfo struct.