feat: niri - spawn at startup

This commit is contained in:
Ryan Yin
2025-08-20 10:55:47 +08:00
parent d517d74bf7
commit 7b1bab3c9b
3 changed files with 104 additions and 72 deletions

View File

@@ -209,15 +209,10 @@ in
(leaf "center-focused-column" "never") (leaf "center-focused-column" "never")
]) ])
# Add lines like this to spawn processes at startup.
# Note that running niri as a session supports xdg-desktop-autostart,
# which may be more convenient to use.
# (leaf "spawn-at-startup" [ "alacritty" "-e" "fish" ])
# You can override environment variables for processes spawned by niri. # You can override environment variables for processes spawned by niri.
(plain "environment" [ (plain "environment" [
# Set a variable like this: # Set a variable like this:
# (leaf "QT_QPA_PLATFORM" "wayland") (leaf "QT_QPA_PLATFORM" "wayland")
# Remove a variable by using null as the value: # Remove a variable by using null as the value:
# (leaf "DISPLAY" null) # (leaf "DISPLAY" null)
@@ -331,60 +326,77 @@ in
]) ])
]) ])
# Window rules let you adjust behavior for individual windows. # Add lines like this to spawn processes at startup.
# They are processed in order of appearance in this file. # Note that running niri as a session supports xdg-desktop-autostart,
# (plain "window-rule" [ # which may be more convenient to use.
# # Match directives control which windows this rule will apply to. # --------------- Terminal ---------------
# # You can match by app-id and by title. (leaf "spawn-at-startup" [ "foot" ])
# # The window must match all properties of the match directive. (leaf "spawn-at-startup" [ "alacritty" ])
# (leaf "match" { (leaf "spawn-at-startup" [ "ghostty" ])
# app-id = "org.myapp.MyApp"; # --------------- Networking ---------------
# title = "My Cool App"; (leaf "spawn-at-startup" [ "clash-verge" ])
# }) # --------------- Browser ---------------
# (leaf "spawn-at-startup" [ "firefox" ])
# # There can be multiple match directives. A window must match any one (leaf "spawn-at-startup" [ "google-chrome-stable" ])
# # of the rule's match directives. (leaf "spawn-at-startup" [ "chromium-browser" ])
# # # --------------- Chatting ---------------
# # If there are no match directives, any window will match the rule. (leaf "spawn-at-startup" [ "Telegram" ])
# (leaf "match" { title = "Second App"; })
# # ============= Window Rules =============
# # You can also add exclude directives which have the same properties. # Get all the window's information via:
# # If a window matches any exclude directive, it won't match this rule. # niri msg windows
# #
# # Both app-id and title are regular expressions. # --------------- Terminal ---------------
# # Literal nix strings can be helpful here. # foot → ws 13
# (leaf "exclude" { app-id = ''\.unwanted\.''; }) (plain "window-rule" [
# (leaf "match" { app-id = "foot"; })
# # Here are the properties that you can set on a window rule. (leaf "open-on-workspace" "1terminal")
# # You can override the default column width. (leaf "open-maximized" true)
# (plain "default-column-width" [ ])
# (leaf "proportion" 0.75)
# ]) # Alacritty → ws 10
# (plain "window-rule" [
# # You can set the output that this window will initially open on. (leaf "match" { app-id = "Alacritty"; })
# # If such an output does not exist, it will open on the currently (leaf "open-on-workspace" "1terminal")
# # focused output as usual. (leaf "open-maximized" true)
# (leaf "open-on-output" "eDP-1") ])
#
# # Make this window open as a maximized column. # Ghostty → ws 14
# (leaf "open-maximized" true) (plain "window-rule" [
# (leaf "match" { app-id = "com.mitchellh.ghostty"; })
# # Make this window open fullscreen. (leaf "open-on-workspace" "1terminal")
# (leaf "open-fullscreen" true) (leaf "open-maximized" true)
# # You can also set this to false to prevent a window from opening fullscreen. ])
# # (leaf "open-fullscreen" false)
# ]) # --------------- Networking ---------------
#
# # Here's a useful example. Work around WezTerm's initial configure bug # Clash Verge → ws 7
# # by setting an empty default-column-width. (plain "window-rule" [
# (plain "window-rule" [ (leaf "match" { app-id = "clash-verge"; })
# # This regular expression is intentionally made as specific as possible, (leaf "open-on-workspace" "0other")
# # since this is the default config, and we want no false positives. ])
# # You can get away with just app-id="wezterm" if you want.
# # The regular expression can match anywhere in the string. # --------------- Browser ---------------
# (leaf "match" { app-id = ''^org\.wezfurlong\.wezterm$''; })
# (plain "default-column-width" [ ]) # Firefox → ws 11
# ]) (plain "window-rule" [
(leaf "match" { app-id = "firefox"; })
(leaf "open-on-workspace" "2browser")
(leaf "open-maximized" true)
])
# Google Chrome → ws 12
(plain "window-rule" [
(leaf "match" { app-id = "google-chrome"; })
(leaf "open-on-workspace" "2browser")
(leaf "open-maximized" true)
])
# --------------- Chatting ---------------
# Telegram → ws 6
(plain "window-rule" [
(leaf "match" { app-id = "org.telegram.desktop"; })
(leaf "open-on-workspace" "3chat")
])
(plain "binds" [ (plain "binds" [
# Keys consist of modifiers separated by + signs, followed by an XKB key name # Keys consist of modifiers separated by + signs, followed by an XKB key name
@@ -512,24 +524,26 @@ in
# #
# For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on # For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on
# will all refer to the 3rd workspace. # will all refer to the 3rd workspace.
(plain "Mod+1" [ (leaf "focus-workspace" 1) ]) (plain "Mod+1" [ (leaf "focus-workspace" "1terminal") ])
(plain "Mod+2" [ (leaf "focus-workspace" 2) ]) (plain "Mod+2" [ (leaf "focus-workspace" "2browser") ])
(plain "Mod+3" [ (leaf "focus-workspace" 3) ]) (plain "Mod+3" [ (leaf "focus-workspace" "3chat") ])
(plain "Mod+4" [ (leaf "focus-workspace" 4) ]) (plain "Mod+4" [ (leaf "focus-workspace" "4music") ])
(plain "Mod+5" [ (leaf "focus-workspace" 5) ]) (plain "Mod+5" [ (leaf "focus-workspace" "5mail") ])
(plain "Mod+6" [ (leaf "focus-workspace" 6) ]) (plain "Mod+6" [ (leaf "focus-workspace" "6file") ])
(plain "Mod+7" [ (leaf "focus-workspace" 7) ]) (plain "Mod+7" [ (leaf "focus-workspace" 7) ])
(plain "Mod+8" [ (leaf "focus-workspace" 8) ]) (plain "Mod+8" [ (leaf "focus-workspace" 8) ])
(plain "Mod+9" [ (leaf "focus-workspace" 9) ]) (plain "Mod+9" [ (leaf "focus-workspace" 9) ])
(plain "Mod+Ctrl+1" [ (leaf "move-column-to-workspace" 1) ]) (plain "Mod+0" [ (leaf "focus-workspace" "0other") ])
(plain "Mod+Ctrl+2" [ (leaf "move-column-to-workspace" 2) ]) (plain "Mod+Ctrl+1" [ (leaf "move-column-to-workspace" "1terminal") ])
(plain "Mod+Ctrl+3" [ (leaf "move-column-to-workspace" 3) ]) (plain "Mod+Ctrl+2" [ (leaf "move-column-to-workspace" "2browser") ])
(plain "Mod+Ctrl+4" [ (leaf "move-column-to-workspace" 4) ]) (plain "Mod+Ctrl+3" [ (leaf "move-column-to-workspace" "3chat") ])
(plain "Mod+Ctrl+5" [ (leaf "move-column-to-workspace" 5) ]) (plain "Mod+Ctrl+4" [ (leaf "move-column-to-workspace" "4music") ])
(plain "Mod+Ctrl+6" [ (leaf "move-column-to-workspace" 6) ]) (plain "Mod+Ctrl+5" [ (leaf "move-column-to-workspace" "5mail") ])
(plain "Mod+Ctrl+6" [ (leaf "move-column-to-workspace" "6file") ])
(plain "Mod+Ctrl+7" [ (leaf "move-column-to-workspace" 7) ]) (plain "Mod+Ctrl+7" [ (leaf "move-column-to-workspace" 7) ])
(plain "Mod+Ctrl+8" [ (leaf "move-column-to-workspace" 8) ]) (plain "Mod+Ctrl+8" [ (leaf "move-column-to-workspace" 8) ])
(plain "Mod+Ctrl+9" [ (leaf "move-column-to-workspace" 9) ]) (plain "Mod+Ctrl+9" [ (leaf "move-column-to-workspace" 9) ])
(plain "Mod+Ctrl+0" [ (leaf "move-column-to-workspace" "0other") ])
# Alternatively, there are commands to move just a single window: # Alternatively, there are commands to move just a single window:
# (plain "Mod+Ctrl+1" [(leaf "move-window-to-workspace" 1)]) # (plain "Mod+Ctrl+1" [(leaf "move-window-to-workspace" 1)])

View File

@@ -34,6 +34,15 @@ in
}) })
]) ])
# ============= Named Workspaces =============
(node "workspace" "1terminal" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "2browser" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "3chat" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "4music" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "5mail" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "6file" [ (leaf "open-on-output" "eDP-1") ])
(node "workspace" "0other" [ (leaf "open-on-output" "eDP-1") ])
# Settings for debugging. Not meant for normal use. # Settings for debugging. Not meant for normal use.
# These can change or stop working at any point with little notice. # These can change or stop working at any point with little notice.
(plain "debug" [ (plain "debug" [

View File

@@ -63,6 +63,15 @@
y = 0; y = 0;
}) })
]) ])
# ============= Named Workspaces =============
(node "workspace" "1terminal" [ (leaf "open-on-output" "HDMI-A-1") ])
(node "workspace" "2browser" [ (leaf "open-on-output" "DP-2") ])
(node "workspace" "3chat" [ (leaf "open-on-output" "HDMI-A-1") ])
(node "workspace" "4music" [ (leaf "open-on-output" "DP-2") ])
(node "workspace" "5mail" [ (leaf "open-on-output" "DP-2") ])
(node "workspace" "6file" [ (leaf "open-on-output" "HDMI-A-1") ])
(node "workspace" "0other" [ (leaf "open-on-output" "HDMI-A-1") ])
]; ];
}; };
} }