Score:0

How to exchange the contents of two screens

kr flag

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

Score:0
cn flag

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.

kiliank avatar
kr flag
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`
FedKad avatar
cn flag
So, were you able to try my script also?
kiliank avatar
kr flag
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?
FedKad avatar
cn flag
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. :(
kiliank avatar
kr flag
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...
FedKad avatar
cn flag
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.
kiliank avatar
kr flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.