How to set the scaling of the display through command line?

If I use a second monitor on Ubuntu 20.04 and if it has the highes resolution (4K), the 1st screen keeps glitching. I found out after many tries that putting it to 175% of fractional scaling then 200% again will fix this issue, however it returns after the screen sleeps

enter image description here

So, I'd like a way to change to 175% and then 200% from command line so I can automate this into a script


Solution 1:

You could probably handle this with xrandr, which is a more powerful tool than the Screen Resolution GUI. See, e.g., Monitor scaling does not work properly.

In your case, that would be

xrandr --output <out1> --scale 1.0x1.0 --output <out2> --scale 1.75x1.75
xrandr --output <out1> --scale 1.0x1.0 --output <out2> --scale 2.0x2.0

Note that you may need to tinker with other flags, e.g. --primary, --mode --pos, --fb.