Looks like the wmctrl
program (from the package of the same name) might be useful for your scripting, it's description is
Wmctrl is a command line tool to interact with an
EWMH/NetWM compatible X Window Manager (examples include
Enlightenment, icewm, kwin, metacity, and sawfish).
Wmctrl provides command line access to almost all the features
defined in the EWMH specification. For example it can maximize
windows, make them sticky, set them to be always on top. It can
switch and resize desktops and perform many other useful
operations.
it's got options like
-r <WIN>
Specify a target window for an action.
-t <DESK>
Move a window that has been specified with the -r action to the desktop <DESK>
.
-l
List the windows being managed by the window manager. One line is output for each
window, with the line broken up into space separated columns. The first column
always contains the window identity as a hexadecimal integer, and the second col‐
umn always contains the desktop number (a -1 is used to identify a sticky window).
If the -p
option is specified the next column will contain the PID for the window
as a decimal integer. If the -G
option is specified then four integer columns will
follow: x-offset, y-offset, width and height. The next column always contains the
client machine name. The remainder of the line contains the window title (possibly
with multiple spaces in the title).
It appears Chrome/Chromium windows might change title depending on what tab is open... so might want these too:
-N name
Set the name (long title) of the window specified by a -r action to name.
-I name
Set the icon name (short title) of the window specified by a -r action to name.
-T name
Set the both the name (long title) and icon name (short title) of the window spec‐
ified by a -r action to name. This action is like using the -N
and -I
actions at
the same time (which would otherwise be impossible since wmctrl can execute only
one action at a time).
-x
Include WM_CLASS in the window list or interpret <WIN>
as the WM_CLASS name.
[For example, chromium.Chromium
]
A quicker "manual" idea
I was looking at the AntiX (also in MX-Linux) package wingrid-antix
and it has shell scripts for moving & resizing windows, they're used as keyboard shortcuts in your window manager, using wmctrl -r :ACTIVE: ...
that gave me this idea:
If you made some keyboard shortcuts to send a window to a specific desktop (numbering starts at zero):
wmctrl -r :ACTIVE: -t 0
And others to send to desktops -t 1
, -t 2
, etc, with shortcut keys like "Ctrl+Super+1", then when a browser window is active all you have to do is press a desktop's shortcut keys and that window will get sent to another desktop.
It's not automatic, but it is push-button easy, and no worries about Chrome's weird window names.
How would the script know what workspace the newly opened windows belong on? Save a list of all windows every few minutes, "just in case"? – Xen2050 – 2019-02-28T21:44:22.567
The solution with the least effort wins :) If there's a way for it to poll periodically "just in case" so I don't have to configure anything or even think, that of course would be awesome. But if that's not possible, a solution where I somehow configure or tell the script "I want the window with this name, or containing a tab with this URL, or whatever, to go to workspace 5", that'd still be a lot better than having to manually move that window every time Chrome restarts. – machineghost – 2019-02-28T21:55:04.033
I had another idea to send any window to a specified desktop, manually but it seems quick & easy. Edited it into my answer FYI (I don't think you get notified of answers being edited, unless it's your own answer) – Xen2050 – 2019-03-14T01:32:50.680