Commit 318fe35

HPCesia <me@hpcesia.com>
2025-10-14 12:24:49
feat: niri named workspace
1 parent 63055c8
Changed files (3)
modules
modules/desktop/shell/niri/appearance/window-rules.nix
@@ -1,14 +1,57 @@
 {lib, ...}: {
   flake.modules.homeManager.niri = {config, ...}: {
     programs.niri.settings.window-rules = [
-      # rules for all windows
       {
+        # rules for all windows
         clip-to-geometry = true;
         geometry-corner-radius = lib.genAttrs ["bottom-left" "bottom-right" "top-left" "top-right"] (_: 15.0);
         tiled-state = true;
         draw-border-with-background = false;
         opacity = config.stylix.opacity.applications;
       }
+
+      # === Workspaces ===
+      {
+        matches = [
+          {app-id = "com.mitchellh.ghostty";}
+        ];
+        open-on-workspace = "1terminal";
+      }
+      {
+        matches = [
+          {app-id = "firefox";}
+          {app-id = "chromium-browser";}
+        ];
+        open-on-workspace = "2browser";
+      }
+      {
+        matches = [
+          {app-id = "org.telegram.desktop";}
+          {app-id = "wechat";}
+          {app-id = "QQ";}
+        ];
+        open-on-workspace = "3chat";
+      }
+      {
+        matches = [
+          {app-id = "org.gnome.Loupe";}
+          {app-id = "deadbeef";}
+          {app-id = "mpv";}
+        ];
+        open-on-workspace = "4media";
+      }
+      {
+        matches = [
+          {app-id = "readest";}
+        ];
+        open-on-workspace = "5read";
+      }
+      {
+        matches = [
+          {app-id = "thunderbird";}
+        ];
+        open-on-workspace = "9other";
+      }
     ];
   };
 }
modules/desktop/shell/niri/keybinding.nix
@@ -142,15 +142,15 @@
       "Mod+Shift+D".action = move-workspace-down;
       "Mod+Shift+U".action = move-workspace-up;
 
-      "Mod+1".action = focus-workspace 1;
-      "Mod+2".action = focus-workspace 2;
-      "Mod+3".action = focus-workspace 3;
-      "Mod+4".action = focus-workspace 4;
+      "Mod+1".action = focus-workspace "1terminal";
+      "Mod+2".action = focus-workspace "2browser";
+      "Mod+3".action = focus-workspace "3chat";
+      "Mod+4".action = focus-workspace "4media";
       "Mod+5".action = focus-workspace 5;
       "Mod+6".action = focus-workspace 6;
       "Mod+7".action = focus-workspace 7;
       "Mod+8".action = focus-workspace 8;
-      "Mod+9".action = focus-workspace 9;
+      "Mod+9".action = focus-workspace "9other";
 
       # TODO: Uncomment below if niri-flake has `move-column-to-workspace`
       # "Mod+Ctrl+1".action = move-column-to-workspace 1;
modules/desktop/shell/niri/workspaces.nix
@@ -0,0 +1,12 @@
+{
+  flake.modules.homeManager.niri = _: {
+    programs.niri.settings.workspaces = {
+      "1terminal" = {};
+      "2browser" = {};
+      "3chat" = {};
+      "4media" = {};
+      "5read" = {};
+      "9other" = {};
+    };
+  };
+}