Manage display arrangement errors in OS X
Sometimes multidisplay arrangements will not stick in OS X after performing software or hardware modifications.
When you connect an external display to your Mac, the system will usually by default resort to its native resolution and arrange it to the right of your main display. You can modify these settings in the Displays system preferences, which should preserve separate settings for each display you use with the system; however, after updating or upgrading OS X the system may not keep these changes and persistently revert to defaults every time your display is attached or when the system restarts.
If you use the default arrangement then this issue may not be much of a problem, but those with custom setups such as having your secondary display in a different position or even using it as the primary monitor, setting it up every time can be irritating.
Display arrangement settings are managed by the OS X window server and saved on a per-user and per-machine basis, which means that the settings for it are in the. Since the host identification is associated to a specific machine's hardware configuration, if you migrate to a new system or if your current system has parts serviced and replaced then it is likely the host identification will change and result in a new settings file being used for the system. However, this reset should only happen once and not result in continual need to change settings.
A more likely problem is simply corruption in the settings file for display arrangements, which is a common reason why settings for any application or process cannot be saved or restored. As a result, the easiest approach to fixing this problem is to clear the window server settings and have them be rewritten by the program, which can be done in one of two ways.
The first approach is have the system clear these settings by running the following command in the Terminal:
defaults -currentHost delete com.apple.windowserver
This will tell the defaults system (the preferences writing routines) to target the specific preferences file for the current computer and remove its contents. While the file itself is not replaced, this routine will clear its contents and set up a basic xml structure in it to accept new preferences settings.
The second approach is to manually remove the file itself, which will force a recreation of it by the window server. A new file will ensure its filesystem properties and permissions are properly inherited and therefore accessible to the window server when running under your account. To remove this file, go to the Finder and choose the Library option from the Go menu (hold the Option key to reveal the Library in this menu if it is missing). Then navigate to the Preferences/ByHost folder in the window that appears, and remove the file called "com.apple.windowserver.NUMBER.plist" (the NUMBER component of the file name will be the current host identification string).
After performing each of these steps, try logging out and logging back into your account to see if new display arrangement settings stick.