2

我的 i3 配置文件中有这些行:

# Startup applications.
exec firefox
exec gnome-terminal
exec nautilus

这些行按预期启动 firefox、gnome-terminal 和 nautilus,但它们启动的顺序是不可预测的。有没有办法以使窗口按我想要的顺序显示的方式启动这些应用程序?(即firefox,然后是gnome-terminal,然后是nautilus)。

4

2 回答 2

3

请参阅i3 中的布局保存

将此添加到 i3 配置文件中:

# 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

创建~/.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$"}]}
    ]
}
于 2019-09-27T08:06:17.153 回答
2

您可以保存布局,以便每个应用程序都被预定义的窗口容器捕获。使其真正自动化需要一些额外的脚本。我的配置中的示例:

i3 配置

assign [class="^Vivaldi-stable$"] 1
assign [class="^Keepassx2$"] 2
assign [class="^Thunderbird$"] 2

....

# last line
exec ~/.config/i3/restore.sh &

恢复.sh

#!/bin/sh

for layout in ~/.config/i3/layouts/*; do
  i3-msg "workspace $(basename "$layout" .json); append_layout $layout"
done

(vivaldi-stable &)
(keepassxc &)
(thunderbird &)

如果你想看完整版,我的 dotfiles在 GitHub 上

于 2018-09-12T19:06:29.720 回答