I have a laptop and a 27 inch monitor. I have Qt running on one monitor and Pycharm on the other. Is there a way to make a key combination to swap all the windows between both screens. The reason is that I want to program on the big screen only. I have already 4 workspaces and all of them are already used.
The output of xrandr:
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 344mm x 193mm
1920x1080 60.2*+ 59.9
1680x1050 60.0 59.9
1600x1024 60.2
1400x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x960 60.0
1360x768 59.8 60.0
1152x864 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
HDMI1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
1920x1080 60.0*+ 50.0 59.9
1920x1080i 60.1 50.0 60.0
1600x1200 60.0
1680x1050 59.9
1280x1024 75.0 60.0
1440x900 59.9
1280x960 60.0
1366x768 59.8
1152x864 75.0
1280x720 60.0 50.0 59.9
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
720x576 50.0
720x480 60.0 59.9
640x480 75.0 72.8 66.7 60.0 59.9
720x400 70.1
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
Best Answer
1. Script to swap all windows from screen 1 --> screen 2 and vice versa
The script assumes the screens are of the same vertical resolution, and the left screen is the primary one. The horizontal resolutions of both screens is searched by the script.
How to set up
The script needs
wmctrl
to be installed:swap_windows
(no extension) in~/.bin
. Create the directory if it doesn't exist already, and make the script executable.~/bin
(it didn't exist yet), either log out/in or run in a terminal:source ~/.profile
.test run the script with the command:
If all works as expected, add shortut key; choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command
The script
2. Script to move (all) windows from one monitor to the other
The script below moves windows in a dual monitor setup from one screen to another, either:
from the left to the right monitor -->
or
from the right to the left monitor <--
Depending on the argument you run it with (
left
orright
)The script (again) assumes the screens are of the same vertical resolution, and the left screen is the primary one. The horizontal resolutions of both screens is searched by the script.
How to set up
The script needs
wmctrl
to be installed:shift_windows
(no extension) in~/.bin
. Create the directory if it doesn't exist already, and make the script executable.~/bin
(it didn't exist yet), either log out/in or run in a terminal:source ~/.profile
.test run the script with the commands
and: shift_windows left
In the first case, windows on your left screen should move to the right screen and in the second case vice versa.
The script
3. Move a single window from one screen to another
Although not literally your question, with just a few lines more, you can either move all windows from one screen to the other, but also a single one (the frontmost) with a key combination.
With the script below, you can move all windows with the command:
or move a single window with the command:
The setup is pretty much the same as the script above (don't forget to install
wmctrl
)The script