window-manager xmonad i3 – Populate a Pre-Configured Workspace in i3wm

i3window-managerxmonad

Is it possible with I3Wm to populate an entire workspace with determined size, position and commands for each window?

I know I can do i3-msg "exec xterm -e 'ls; bash'" to create a new window, but I can't specify his position and size.

Maybe there is also an alternative by declaring via JSON the layout or something like that?

Best Answer

Since version 4.8, something like that is part of i3 and there's a detailed guide on the website, but here's a short version:

Once you've set up a workspace like you want it to be, save its layout with

i3-save-tree --workspace <whichever workspace you want> > ~/.i3/layout-ws-<xyz>.json

into the file ~/.i3/layout-ws-xyz.json. You'll then need to edit that file to enable criteria that match windows in the layout.

After that, you can restore that layout with

i3-msg "workspace <your workspace>; append_layout ~/.i3/layout-ws--<xyz>.json"

This will open placeholder windows on that workspace and when a window matching the criteria enabled in the layout file appears, it will be placed in the corresponding placeholder window.

Related Question