Change workspace of multiple windows at once (i3)

Is it possible to transfer all windows in one workspace to another one whilst maintaining their layout?

This is practical for dual monitor. For example on the laptop screen I may have 3 windows which are tiled in a particular way (say, 1 left, 2 right and on top of each other) and I want to transfer them to the monitor display in a new workspace. I know that it is not too hard to shuffle windows around to recover layout, but it seems like a command that should exist (quite possibly it does and I’m not aware of it).

i’ve never seen that.
https://i3wm.org/docs/userguide.html

1 Like

I think you want to transfers all the workspace from a monitor to another one? Try this:

#move focused worksapce
bindsym $mod+Shift+o move workspace to output left
bindsym $mod+Shift+p move workspace to output right

1 Like

It was once possible to move up the tree with focus parent command and then send them all to workspace like any other windows. I haven’t used i3 in a while tho.

https://i3wm.org/docs/userguide.html#_focus_parent

Yes, this is possible and is an action I perform all the time. Here are the two common scenarios:

Moving Between Workspaces

If you’re looking to move all of the applications you have open on screen (a workspace) to another workspace, then you’ll have to “focus” all of the windows on that workspace. To do this, you would use the key combination $mod+a. This basically tells i3 that you’d like the next command to take affect on all the windows within a container.

Note: You may have to issue the $mod+a command a few times to capture all of the windows on the screen. As @airclay mentioned, the documentation as more details on how “containers” work.

So, to use your example, let’s assume your windows are on workspace one. If you were focused on the left window, then issuing the $mod+a key combination would select the “parent container” (all the windows, including the two to the right of your focused window). Then, you could use the key combination $mod+3 to move all the windows to workspace three.

Moving Between Monitors

In this scenario, you have your windows on a primary monitor, but you’d like to move them all to a secondary monitor. This is achieved using the move workspace command as mentioned by @sixwinger. You can find more information in the “Moving workspaces to a different screen” section of the i3 manual.

What’s key to understand is that this action is only possible if you have it mapped within your i3 config. As an example, here’s what I’ve added to my config file (~/.config/i3/config):

# move focused workspace between monitors (outputs)
bindsym $mod+Ctrl+greater move workspace to output right
bindsym $mod+Ctrl+less move workspace to output left

So, to use your example once more, let’s assume you have your windows laid out on workspace two which is currently displayed on your primary monitor. You’re ready to work from your laptop (because everyone needs a coffee break) and so you want to move all the windows to your laptop’s display. Assuming you’ve added the mapping above, then you would issue the $mod+ctrl+> key combination to move the workspace to the laptop screen.

Of course, the laptop has to be configured as “right” of your primary monitor. Otherwise you’d have to use the other key combination.

What’s important to note here is that the windows did not move to a new workspace, but the workspace itself (workspace two) moved to the laptop monitor.

3 Likes