I'd like to map a keyboard shortcut (Alt + Space) to a series of actions and I'd love some help writing the script for it.
I have three monitors. The built-in laptop monitor, and two external monitors. When I'm coding I like to have code in one monitor, the browser in another, and a third item (Photoshop, or a file navigator) in the third monitor.
But, I find myself with a neck cramp looking to the left writing code, or looking right making changes in the browser.
The keyboard shortcut I'd like should shuffle windows across monitors. I the three monitors have code editor, browser, and nautilus in each of them in that order, then pressing Alt + Space once would change that to Nautilus, Code Editor, Browser. Pressing it again would change it to Browser, Nautilus, Code Editor, and pressing it a third time would restore the first setup.
How might I do this for any number of things that might be displayed on each monitor? Like if I happen to have three windows open in the first monitor, two terminal windows in the second, and five browser windows in the third, shuffling what's on each screen? Maybe using workspaces and reordering them?
Some help would rock : )
Update: On Gnome by the way.
It seems you want to swap windows between screens.
For Wayland, solutions are specific to the window manager.
For X11, there are options that will work with any window manager. You'll need to write some code to tie everything into a cohesive script. If screens are logically side-by-side, you can use modular arithmetic to calculate positions.
Use
xrandr
to change the position of the screens. Doesn't work too well if the screens are different sizes.Use
wmctrl -p -G -l
to get a list of Windows. Then move them with:You can calculate position
x,y
and sizeW,H
as desired. Use-1
to keep the same value.xdotool
is another tool that may be of use.I've managed this with
wmctrl
. I mapped a few bash scripts to the Num Lock to move a window quickly to a new position. Here is my approach. For example, to move to the right screen: