Hi, I'd like some more comments from you on this: 
First of all,
xrandr --auto enables all inactive outputs, so why do you turn some output off before? It has no effect.
Secondly, on my setup with two monitors (laptop + HDMI connected), the output that was off is set to clone the other output (effectively
--same-as option). Though technically right, it is misleading to say that "This scrip auto sets best screen size" (for all available outputs I assume), because the monitor with higher resolution is padded with black space around the picture of the smaller output.
- thank you for mension. I'm using laptop & monitor, but using same output, usually close laptop. When changing from different monitor, xrandr --off will clear old resolution, so that new one will be used. -- Whille