data="$(xrandr -q | grep connect )" last='' echo "$data" | grep ' connected ' | while read output rest; do xrandr --output $output ${last:+--right-of} $last --preferred last=$output done