0

I use two monitors: one directly in front of me and one on the right. It happens frequently that I want to move the entire content of the right screen to the center screen and vice versa. The best method I found so far is using the combination (function + shift + left/right). With this method however, I need to do it with every window.

Is there a build in function in Ubuntu or an application to achieve this feature?

If not, what would be an effective approach to implement this on my own?

Thanks for any help on this,

Cheers

kiliank
  • 1
  • 1

1 Answers1

0

Note: I am posting this as an "answer", because of the amount of detail it contains, I cannot post it as a comment. If you comment to my "answer", I may be able to expand it to a real answer.


I do not have two monitors in my environment, however I have defined two workspaces in my GNOME environment:

$ wmctrl -d
0  * DG: 1920x1080  VP: 0,0  WA: 0,0 1920x1046  Workspace 1
1  - DG: 1920x1080  VP: N/A  WA: 0,0 1920x1046  Workspace 2

I created the following script to move all windows from one workspace to the other:

#!/bin/bash
wmctrl -l | while read win desk rest ; do
  let ndesk=1-desk
  echo $win $desk →  $ndesk
  wmctrl -i -r $win -t $ndesk
done

I do not know whether this also applies to monitors. Can you first try the command wmctrl -d and comment? Note: You can install the wmctrl command using sudo apt install wmctrl.

FedKad
  • 10,515
  • Thank you for you reply! The Output of wmctrl -d is: `0 * DG: 1920x1080 VP: 0,0 WA: 72,27 1848x1053 Workspace 1

    1 - DG: 1920x1080 VP: N/A WA: 72,27 1848x1053`

    – kiliank Jul 04 '21 at 08:55
  • So, were you able to try my script also? – FedKad Jul 04 '21 at 09:00
  • I did a mistake the correct output to wmctrl -d is: 0 * DG: 3840x1200 VP: 0,0 WA: 72,27 3768x1173 Workspace 1 1 - DG: 3840x1200 VP: N/A WA: 72,27 3768x117 It seems that the script moves things to a different workspace, but it does not exchange the contents of the screens. Is there a way to assign screens to specific workspaces? – kiliank Jul 04 '21 at 09:06
  • I am assuming that the workspaces you listed above are for each screen (monitor). So wmctrl moves the windows between workspaces of the same screen, but not between screens. We may need to investigate other options. :( – FedKad Jul 04 '21 at 09:14
  • But thanks for mentioning wmctrl. With this I could find this post: https://askubuntu.com/questions/702071/move-windows-to-specific-screens-using-the-command-line and I might be the solution. But first I need to understand what exactly is going on there... – kiliank Jul 04 '21 at 09:19
  • Yes. That Q&A mentions about the -e option of wmctrl which is related to the output (list of monitors) produced by xrandr. That may lead to a solution for your question. – FedKad Jul 04 '21 at 09:22
  • Also looking at the resolutions (3840x1200) that I got from wmctrl -d it almost looks like ubuntu does not really have a concept of two different screens but it just merges all screen space into a large virtual screen. So changing the contents of the screen amounts to moving the windows to specific positions on the "merged screen". Which might be the reason why there is not one simple command for it. – kiliank Jul 04 '21 at 09:32