3

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?

1
  • "I can't specify his position and size" I'm not an i3 user, but unless it does something funny, you should be able to use the -geometry=WxH+X+Y switch to xterm. The W and H are in characters, the X and Y are in pixels. Note you could also use the snazzier terminal from (e.g.) XFCE stand-alone if you want, which uses the same style geometry spec. The GNOME terminal may be portable too; KDE's konsole definitely is but does not allow you to dictate the geometry. Commented Aug 25, 2014 at 15:36

1 Answer 1

5

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.

3
  • Thanks for this tip, I tried it and it works well for saving and restoring workspaces ! But I don't manage to execute any command into these windows (via the JSON). There is only some text written on it without anything else. Commented Aug 26, 2014 at 14:01
  • 1
    The text in the placeholder windows are the criteria that new windows need to match to be placed into the placeholder window, so if the text in a placeholder window is class="^Google-chrome$", you still need to start an application whose window has that specific class; the application will not be started automatically. Commented Aug 26, 2014 at 14:13
  • Got it! I set the right swallows[0].class then launched i3-msg "workspace 1; append_layout /path/my/layout.json; [class='xterm'] exec xterm and worked like a charm. This JSON declaration is definitely an awesome feature, thank you! Commented Aug 26, 2014 at 15:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.