Search code examples
i3

How to automatically start programs in a specific order?


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).


Solution

  • 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$"}]}
        ]
    }