Apple script to change main display
I wrote a command line tool called displayplacer that will help with this. You can specify the resolution and positioning of your various monitor setups. Setting a screen with origin:(0,0) will make it the main display with the white bar in the settings.

Execute displayplacer list to get your screen ids.

Example profile 1 with MacBook screen
displayplacer "id:&lt;4kScreen1&gt; res:3840x2160 scaling:off origin:(0,0) degree:0" "id:&lt;4kScreen2&gt; res:3840x2160 scaling:off origin:(-3840,0) degree:0" "id:&lt;MacBook&gt; res:1440x900 scaling:on origin:(3840,0) degree:0"

Example profile 2 without MacBook Screen
displayplacer "id:&lt;4kScreen1&gt; res:3840x2160 scaling:off origin:(0,0) degree:0" "id:&lt;4kScreen2&gt; res:3840x2160 scaling:off origin:(-3840,0) degree:0"

Also available via Homebrew brew tap jakehilborn/jakehilborn &amp;&amp; brew install displayplacer