Saturday, June 16, 2018

xrandr: why not just have --setcvtmode 1920x1080@60

I have fiddled with xrandr a lot and I wish that it'd be easier to just specify a resolution and refresh rate in one line.

Something like

xrandr --output VGA-1 --setcvtmode 1920x1080@60

instead of having to do:


$ cvt 1920 1080 60
# 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


then copying and pasting the modeline into xrandr --newmode

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

and then adding the mode to the VGA-1

$ xrandr --addmode VGA-1 "1920x1080_60.00"

and then finally actually setting the mode

$ xrandr --output VGA-1 --mode "1920x1080_60.00"


You can do things like use awk:

xrandr --newmode `cvt 1920 1080 60 | awk 'NR==2 {for (i=2;i<=NF;i++) printf("%s ",$i);}'`
xrandr --addmode VGA-1 `cvt 1920 1080 60 | awk 'NR==2 {for (i=2;i<=2;i++) printf("%s ",$i);}'`

but why not have it all in a single command, and maybe have an option for trying it out and reverting to the previous settings in 10 seconds, in case your monitor doesn't like it.



something like:

xrandr --output VGA-1 --setcvtmode 1920x1080@60 --trymode 10

That would make it much less cumbersome. Why does it have to be hard?

No comments:

Post a Comment