Reputation: 31
I have a 3 display setup at work with the following order (from left to right):
macOS Version: 10.13.6
Most likely when I reboot, the order is gone and I have to reset it through System Preferences -> Display -> Arrangement
Is there a way to change the arrangement through command-line or applescript?
Upvotes: 2
Views: 1855
Reputation: 871
I got tired of that same problem and manage to reduce the 'displayPlacer' mentioned in the link of Mark Setchell to fix this particular problem to this :
#include <IOKit/graphics/IOGraphicsLib.h>
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>
#include <math.h>
#include <stdio.h>
int main(int argc, const char * argv[]) {
CGDirectDisplayID screenList[3];
CGDirectDisplayID external1;
CGDirectDisplayID external2;
CGGetOnlineDisplayList(INT_MAX, screenList, NULL);
if(CGDisplayIsMain(screenList[0])){
external1 = screenList[1];
external2 = screenList[2];
}else if(CGDisplayIsMain(screenList[1])){
external1 = screenList[0];
external2 = screenList[2];
}else{
external1 = screenList[1];
external2 = screenList[2];
}
CGDisplayConfigRef configRef;
CGBeginDisplayConfiguration(&configRef);
CGConfigureDisplayOrigin(configRef, external1, CGDisplayBounds(external2).origin.x, CGDisplayBounds(external2).origin.y);
CGConfigureDisplayOrigin(configRef, external2, CGDisplayBounds(external1).origin.x, CGDisplayBounds(external1).origin.y);
CGCompleteDisplayConfiguration(configRef, kCGConfigurePermanently);
}
My C was rusty it may not be very clean... It simply finds the 2 externals screens and reverse their position. It wouldn't be very hard to make preconfigured multiple positions if you change between two setups. It is in C but does the job.
Upvotes: 3