This question already has an answer here:

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?


marked as duplicate by karel, Sergiy Kolodyazhnyy, Goddard, Eric Carvalho, user364819 May 31 '18 at 20:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.