The fastest and easiest way is to save the intended layout and restore it when needed on a fresh workspace. (Since version 4.8 i3 can save and restore layouts (see here)
Luckily with gnome-terminal
you can set the window role with a command line parameter: --role ROLE
, which makes it quite easy to assign specific positions for specific windows.
To start your terminals you can just use the following script and run it on an empty workspace:
#!/bin/bash
WS_LAYOUT_FILE=/some/where/layout
declare -A IPs
IPs=(
[W1]=xx.xx.xx.01
[W2]=xx.xx.xx.02
[W3]=xx.xx.xx.03
[W4]=xx.xx.xx.04
[W5]=xx.xx.xx.05
[W6]=xx.xx.xx.06
)
SSH_USER=username
i3-msg append_layout "$WS_LAYOUT_FILE"
for window in ${!IPs[*]};
do
gnome-terminal --role "$window" -e "ssh $SSH_USER@${IPs[$window)}" &
done
The layout file (/some/where/layout
in the example) for your case looks like this:
{
"border": "normal", "floating": "auto_off",
"layout": "splith", "type": "workspace",
"nodes": [
{
"border": "normal", "floating": "auto_off",
"layout": "splitv", "percent": 0.333333333333333, "type": "con",
"nodes": [
{
"border": "normal", "floating": "auto_off",
"layout": "splitv", "percent": 1, "type": "con",
"nodes": [
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 0.333333333333333,
"name": "W1",
"swallows": [ { "window_role": "^W1$" } ]
},
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 0.333333333333333,
"name": "W2",
"swallows": [ { "window_role": "^W2$" } ]
},
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 0.333333333333333,
"name": "W3",
"swallows": [ { "window_role": "^W3$" } ]
}
]
}
]
},
{
"border": "normal", "floating": "auto_off",
"layout": "splitv", "percent": 0.333333333333333, "type": "con",
"nodes": [
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 0.5,
"name": "W4",
"swallows": [ { "window_role": "^W4$" } ]
},
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 0.5,
"name": "W5",
"swallows": [ { "window_role": "^W5$" } ]
}
]
},
{
"border": "normal", "floating": "auto_off",
"layout": "splitv", "percent": 0.333333333333333, "type": "con",
"nodes": [
{
"border": "normal", "floating": "auto_off",
"type": "con", "percent": 1,
"name": "W6",
"swallows": [ { "window_role": "^W6$" } ]
}
]
}
]
}
append_layout
opens placeholder windows as defined in the layout file. If a window is created that matches the rules in swallow
(in this example only window_role
is checked) i3 puts it in place of the placeholder.