How to set default display for new windows in Gnome 3

I have 2 displays, a monitor and a TV. The first one I use all the time and it has set as primary in Gnome settings, but a TV is turned on only when watching movies from a sofa. Mainly, everything is going as expected, but some apps opens at the TV which is turned off at the moment, thus, I have to turn it on and drag window to the monitor and it happens all the time with a certain apps, i.e. qBittorrent.

I spent a lot of time with Google but I failed to find a way to let all apps appear on primary display.


Solution 1:

Kind of old question I guess, but I reckon there are more people with this problem.

I don't think there is a setting to open all programs on the primary display on Gnome.

But as a workaround you can enable workspaces only on the primary display, and make rules for all the programs you want to force to primary.

Start gnome-tweak-tool.

Workspaces -> Turn on "Workspaces only on primary display"

Extensions -> Turn on "Auto move windows"

Press the gear to enter settings, press "Add Rule", choose program and workspace number.

Make a rule for each program you want to display on primary.

Solution 2:

TLDR (this solution comes with NO WARRANTY):

  1. Comment out or delete the <primary>yes</primary> line(s) in your ~/.config/monitors.xml file;
  2. Restart Gnome with Alt+F2rEnter;
  3. With the focus on the primary monitor, experiment launching the apps that were arbitrarily opening windows in the secondary monitory.

I've accidentally solved this problem in my dual monitor setup. Don't even understand why it worked, but it worked:

While inspecting the ~/.config/monitors.xml file, I mistakenly thought that both monitors were flagged with the <primary>yes</primary> entry. So I tried to fix what I thought was a bad config in what I tought was the entry for the secondary monitor, changing it to <primary>no</primary>. After restarting Gnome, it worked like a charm ―case solved! But later, when I was looking at that file again in order to write this answer, I've noticed that there were actually two configurations in it, each listing my two monitors, and only the built-in notebook monitor had the <primary> tag under it in both of them...

What I have actually done was:

<configuration> (currently in use)
  <logicalmonitor> (built-in display)
    <primary>yes</primary>  -->  <primary>no</primary>
    ...
  </logicalmonitor>
  <logicalmonitor> (external display, no <primary> tag)
    ...
  </logicalmonitor>
</configuration>
<configuration> (alternative)
  ...
</configuration>

I undid the change and (after restarting Gnome again) the bad behavior came back. Deleting or commenting out that line gives the same results as changing the yes to no. I would recommend to just comment it out.

Did some tests, it didn't break anything until now, as this specific setting isn't respected anyway. For example, without modifying the monitors file (with the built-in monitor flagged as "primary: yes"), the external display always ends as the primary monitor when I switch from "External Only" to "Join Displays" using the Super+P default keyboard shortcut.

In summary, it's a mess. But a bit less messier with this serendipitous solution.