Reputation: 10950
I have these lines in my i3 configuration file:
# Startup applications.
exec firefox
exec gnome-terminal
exec nautilus
These lines start firefox, gnome-terminal and nautilus as expected, but the order in which they start is unpredictable. Is there a way to start these applications in a way that makes the windows appear in the order that I want? (i.e. firefox, then gnome-terminal, then nautilus).
Upvotes: 3
Views: 6189
Reputation: 10950
Refer to Layout saving in i3.
Add this to the i3 configuration file:
# Create specific layout for applications.
exec --no-startup-id "i3-msg 'workspace 1; append_layout ~/.config/i3/workspace-1.json'"
# Start applications.
exec firefox
exec gnome-terminal
Create ~/.config/i3/workspace-1.json
:
// Layout of a workspace.
{
"layout": "tabbed",
// To get a window's class name, run xprop and click on the window.
// You will see the following output:
// WM_CLASS(STRING) = "InstanceName", "ClassName"
// Alternatively, "swallow" by the window's title.
"nodes": [
{"swallows": [{"class": "^Firefox$"}]},
{"swallows": [{"class": "^Gnome-terminal$"}]}
]
}
Upvotes: 3
Reputation: 2477
You can save layouts so that each application is captured by a predefined window container. Making it truly automatic requires a little extra scripting. Examples from my configuration:
assign [class="^Vivaldi-stable$"] 1
assign [class="^Keepassx2$"] 2
assign [class="^Thunderbird$"] 2
....
# last line
exec ~/.config/i3/restore.sh &
#!/bin/sh
for layout in ~/.config/i3/layouts/*; do
i3-msg "workspace $(basename "$layout" .json); append_layout $layout"
done
(vivaldi-stable &)
(keepassxc &)
(thunderbird &)
If you want to see the full version, my dotfiles are on GitHub.
Upvotes: 2