1

Question

Using a shell scripting language, python, or anything, how can I move a window from one viewport to another?

While I'm pretty desparate, I'd prefer the solution to work in the background. As in, not activate window 1, move window 1, active window 2, move window 2, ..., while I have to sit and wait for all this to happen. (I'll refer to this as the slow activation problem.)

I'd even appreciate references to where else I should ask this question, like forums of people knowledgeable about Linux and window managers.

Environment

I'm using Gnome Flashback with Compiz (not Unity or Metacity). I'm on Ubuntu 14.04, but hopefully solutions would work on other versions as I intend to upgrade.

What I've tried

Only command line stuff with existing programs.

wmctrl

First, wmctrl doesn't really work apparently with compiz. Here's what I get with wmctrl -d:

$ wmctrl -d
0  * DG: N/A  VP: N/A  WA: N/A  N/A

wmctrl -l isn't completely useless, but it doesn't show all windows. For example, I ran it just now and it reported 8 Chrome windows but I know I have at least 21. Slack is open but isn't in the list of windows.

compiz-dbus plugin

I used the compiz-dbus plugin with the put plugin, and tried using ./compiz-send.py put put_viewport_1_key, but this has several problems:

  1. It only works with the active window, thus gives the "slow activation" problem mentioned above. And that's presuming I could use another tool to find a window by title and activate it.
  2. It's buggy for maximized windows, which 95% of my windows are. For me, it'll sometimes move the window's viewport, but always put it on my middle monitor, even if it started on my right monitor. Othertimes, it'll move the viewport, then move it back! (and still put it on the middle monitor). Obviously this is no good.

Backstory

I hate restarting my computer, because all windows start on a single viewport, and it takes me several minutes to move all my windows back to the viewports they were previously on. For example, I'll have several Chrome windows on viewport 1, several on viewport 2, etc. That's a lot of window moving, every time I restart my computer.

Often, I don't restart my computer for extended periods because of this pain, which is bad for security fixes, etc. Why do I have so many windows open? I'm a contractor and work on several projects simultaneously, each with its own concerns requiring web research, code writing, command line stuff, etc. I have 32 GB of RAM so many windows is not a performance problem.

Generally the windows are easy enough to identify by title where I'd like them to be. For example, I always want "Gmail - Google Chrome" to be on viewport 1.

2 Answers2

1

It is also possible to use the Place Windows plugin in the CompizConfig Settings Manager to have programs always open on a certain viewport. The Place Windows plugin can be found under the Window Management category.

Once inside the Place Windows plugin go to the Fixed Window Placement tab at the top. At the bottom you will see the Windows with fixed viewport. Click the New button to add a new program. Next click the green plus to configure what windows should be positioned. Use a Type of Window Class. Use the Grab button to get the information from an open window of the type you want to position when started. You will also need to set the horizontal and vertical viewport location where you want the program positioned on startup.

This information is from a webupd8.org article titled "Make Applications Always Open On A Given Workspace (Viewport) Using Compiz". There is also a link to a screencast on Youtube that goes through these steps on that page.

  • This is great, thanks! It worked for me when I tested it with the Calculator app. I'm not sure how it'll play around with tabbed windows like Chrome but I'll try it out. – Tyler Collier Jul 31 '17 at 21:07
0

See this answer to the question "Save Unity Desktop Session". The answered supplies a link to a script, ~/session.config that helps you setup a script, ~/.sessionconfig with autostart up desktop file, ~/.config/autostart/sessionconf.desktop.

I have used this script for some time now. The only gotcha is that it uses the default physical display dimensions. This means if you plug an external display adapter into your laptop with different dimensions the programs will not be placed in the desired viewport.