2

I want to write a script to clone my current desktop to another monitor, but I can't get the second monitors resolution to be set to the resolution of the primary monitor.

How can I automatically set the resolution of the second monitor to be the same as the first monitor?

1 Answer 1

1

It depends on what is the output of your xrandr when both monitors are connected. If it is for example something like this:

$ xrandr
Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400
VGA disconnected (normal left inverted right x axis y axis)
LVDS connected 1400x1050+0+0 (normal left inverted right x axis y axis) 286mm x 214mm
   1400x1050      60.0*+   50.0  
[...]

Then you can use sed to get the resolution of your primary monitor (here LVDS) and set that to your secondary monitor (here VGA):

RESOLUTION=$(xrandr | sed -nr 's/LVDS connected ([0-9]+x[0-9]+).*/\1/p')
xrandr --output VGA --mode $RESOLUTION

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.