Force programs to open on the main monitor

Hi,

I'm having a bit of an issue with my setup. I run a triple monitor setup, and i have run in to a bit of a problem. Programs and desktop icons prefers to open on my "number 3" monitor, the one that i placed to the left, instead on my primary monitor in the middle.

Is there any way to force programs to open on my primary monitor?

I know it's a bit of an issue with x11, but on linux mint cinnamon the same issue does not appear.

1 Like

Hi, @zeanox and welcome to the Ubuntu MATE Community!

Welcome, @zeanox! Perhaps it would just take renumbering your monitors so that your #3 becomes your #1? Or did I misunderstand your question?

1 Like

I have tried to rearrange the cables to make the middle one "number 1", but programs still open on the monitor to the left no matter what monitor it is.

It will always pick the monitor to the left

Out of curiosity, do you have any "configuration" on Cinnamon which identifies that centre monitor as the "goto" zone?

Within the "Preferred Applications" App, is there an additional Panel (on Cinnamon) which offers a configurable selection of which "display" is the "goto" for opening?

Also, are there any "gsetting" values identifiable via dconf-editor which hint at possible "unpublished" settings which could be applicable in the UbuntuMATE environment?

Is there somewhere that you can specify the 3 displays a one zone, into which the App will open "centered", therefore on the middle display?

1 Like

No, it's just a standard installation im using as a test system without much setup.

I don't see such a setting?

I don't think so, but im not quite sure what to look for?

I don't know what this refers to?

1 Like

What I meant was is the entire visible "Desktop Surface" a single "logical viewport", which is then cut up and assigned piecemeal to each of the 3 displays? Or are they 3 separately managed desktops? Or only one Desktop, with 2 auxiliary displays for designated output "types"?

1 Like

There doesn't seem to be a built-in ability to do this under Gnome or MATE, but you could try one of these options:

Devilspie2. This lets you write simple scripts to control window behavior, including which monitor (screen) a window appears on.
sudo apt install devilspie2

wmctrl. This is a command-line tool to interact with X Window properties.
sudo apt install wmctrl

Another approach is to use a .desktop file and include the monitor you want the app to use when it launches.

You can also try using --windowed and --monitor flags when launching an app. This may not work with all apps.

Finally, while this solution was offered as a Windows issue, it might give you some idea of what you can try: Making Windows open applications on a specific monitor - Artiom's Sketchpad

2 Likes

I think it's 3 separate desktops.

1 Like

This is part of what i was looking for, might see if i can get some of it to work (hopefully)

1 Like

I asked to chatgpt to create a script to you.

Here is the generic script to launch any application on a specific monitor (output) under Ubuntu with X11, using xrandr and wmctrl.

Make sure these tools are installed:
sudo apt install wmctrl

chmod +x launch_on_screen.sh
./launch_on_screen.sh DP-1 firefox Firefox
#!/bin/bash

# --- User-configurable parameters ---
OUTPUT_NAME="$1"      # Example: DP-1, HDMI-0, eDP-1
APP_COMMAND="$2"      # Example: firefox
WINDOW_NAME="$3"      # Example: Firefox (as seen in wmctrl -l)

# --- Basic usage check ---
if [[ -z "$OUTPUT_NAME" || -z "$APP_COMMAND" || -z "$WINDOW_NAME" ]]; then
    echo "Usage: $0 <output_name> <app_command> <window_name>"
    echo "Example: $0 DP-1 firefox Firefox"
    exit 1
fi

# --- Get screen position (x,y) for the given output ---
SCREEN_POS=$(xrandr --query | grep -A1 "^$OUTPUT_NAME connected" | tail -n1 | grep -oP '\d+x\d+\+\K\d+\+\d+')
if [[ -z "$SCREEN_POS" ]]; then
    echo "Error: output $OUTPUT_NAME not found or not connected."
    exit 2
fi

X=$(echo "$SCREEN_POS" | cut -d'+' -f1)
Y=$(echo "$SCREEN_POS" | cut -d'+' -f2)

# --- Launch the application in background ---
$APP_COMMAND &

# --- Wait for the window to be created ---
sleep 2  # Adjust this delay if needed depending on the application

# --- Move the window to the desired screen position ---
wmctrl -r "$WINDOW_NAME" -e 0,$X,$Y,-1,-1
2 Likes