Ubuntu – Set primary monitor on 16.04

displaymultiple-monitors

All windows opens on left monitor and all new files gets saved there, I want my right monitor as my primary monitor so all this happens there.

As the picture below shows I have set the launcher on my right monitor but that doesn't help with my problem.

Display settings

Best Answer

I had this same problem, as well as several other problems related to having multiple monitors.

It turns out this is an open unsolved bug for Ubuntu; meaning the solution link posted in the above comment does not actually contain a solution that fully works. See open bug report here: https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1425000

Fortunately I spent a bunch of time figuring out how to configure this as well as the orientation of the login screens but that's explained in a different thread (I have four monitors and login orientation was wrong but it's all sorted now, if you also have this issue see solution here: Where does Unity/Unity-Greeter Load X Configuration From?)

The quick simple solution to the problem of not being able to set your default display, and/or the default display getting reset after reboot is to put a short shell command that changes the primary monitor as one of your "Startup Applications" which will automatically run every time you log in (this should work for any recent Ubuntu running the Unity display manager which is the default display manager and probably other DMs but I didn't test that):

1) First, you will want to install arandr to easily find your monitor display names, run this in a shell:

sudo apt-get install arandr --upgrade

2) Next, run the arandr command and look at it's user interface that loads (it will probably load on the wrong screen since you haven't configured anything yet).

3) Now, take note of which display (the names should be something like HDMI-# for hdmi or DP-# for display port, DVI-I-# for digital video, etc). The label should be big and obvious once you run arandr. You can either write down the display name, or just keep arnadr window open, so you can see it, and launch a new shell if you need to for the next part. My default display is called DP-4 used in the next example, but undoubtedly yours will be different so take note for the next step.

4) Next, load up the "Startup Applications" tool. You can find it by going to the dash and typing "Startup Applications" and Ubuntu will find it for you, or you can run this command in a shell:

gnome-session-properties

5) Now, from within the Startup Applications tool, click the "Add" button and add a new program to run upon logging in. A window will pop up asking you what to run, here is what to type:

  • Name: Set Default Monitor

  • (Note: put any name you want)

  • Command: xrandr --output DP-4 --primary

  • (Note: change DP-4 *to whatever monitor code you found you want to be the default display when you ran *arandr)

  • Comment: Leave blank or put a reminder for yourself later what this does.

Reboot to fully test it worked and that should do the trick. If you aren't sure if the command will work and want to test it first, you can run xrandr --output DP-4 --primary (again, replace DP-4 with your default monitor) from a shell then launch a window and see if it shows up on the correct default monitor. But in order to have this save and work each time, to work around the bug, you need to add that command to Startup Applications.

UPDATE: It seems here is a second step / part 2 to this solution in order for it to fully work. After several days of testing on Ubuntu 16.04, I discovered it was also necessary to modify ~/.config/monitors.xml to specify the primary monitor. If you don't set the primary monitor in ~/.config/monitors.xml then it appears some windows and/or programs obey the xrandr command and some do not. All you need to do in order to perform this step is open up ~/.config/monitors.xml in a text editor like gedit and set the <primary> tag to yes for the display monitor you want as primary and no for all other displays. Here are the steps:

1) In a shell, first backup your existing monitors.xml file so you can restore it if something unexpected goes wrong during the editing process:

cp ~/.config/monitors.xml ~/.config/monitors_OLD.xml

2) Open monitors.xml in gedit to change the config settings tags:

gedit ~/.config/monitors.xml

3) Now, inside of the gedit editor window, find the output tag labeled for the monitor you want to be primary, then under that <output> block, change the <primary> tag to yes. Be sure to look at all other monitors and change the primary tag for all the other monitors to no.

For me, doing these two things has solved the problem in all cases I've encountered so far.