How can i move a window to a specific monitor (Ubuntu 20.04)?

How do I move a window to a specific monitor with code? I have two screens where one needs to run an app in full screen, and the other needs to play a video in full screen.


Solution 1:

You can use xdotool to achieve what you want.

I don't think there is any setting to move to one screen or another, you just need to set each window position (x and y position) and geometry (size). For example, run the following command in a terminal window

xdotool search --name "WINDOW TITLE HERE" getwindowgeometry

And then move the window around and between different monitors and you will see that it's just a different (top-left) x/y position depending on your monitor setup and resolution.

So you can experiment and code scripts to get the relevant window ID's and then set the position with the windowmove command and geometry with the windowsize command.