3

I have a laptop with a hidpi display, I'm using Ubuntu 18.04 with a resolution of 3840x2160 and 200% scale. Everything software I use looks fine with the exception of one so I would like to write a script so I can automatically change, let's say scaling to 100% and resolution to 1024x768.

Is there a way to do this?

Eliah Kagan
  • 117,780
  • 3
    To reviewers: This duplicate doesn’t address the scaling in any way. – dessert May 29 '18 at 06:29
  • Suggest you visit https://askubuntu.com/questions/771673/ubuntu-gnome-and-high-resolution-screen-icons-in-qt-apps-are-too-small-how-to/826405#826405 – K7AAY May 31 '18 at 18:08

1 Answers1

5

This is an X Server solution and may not work with Wayland.

You can use randr for that, just determine the output name and available modes with xrandr and use the --mode and --scale options to change the settings. Provided this mode already exists, this would change the output DP2 to 3840x2160 with 200% scaling:

xrandr --output DP2 --mode 3840x2160 --scale 2x2

This changes to 1024x768 with 100% scaling:

xrandr --output DP2 --mode 1024x768 --scale 1x1

Further reading:


To automate this I’d use xdotool, e.g. to call xrandr as soon an xterm window gets focus:

xdotool search --class xterm behave %@ focus exec xrandr
dessert
  • 39,982