From 7094e6981418e930ba7bac6e56a9f636e223ab4f Mon Sep 17 00:00:00 2001
From: Myned <dev@bjork.tech>
Date: Wed, 12 Feb 2025 13:20:53 -0600
Subject: [PATCH] niri: launch apps at startup

Signed-off-by: Myned <dev@bjork.tech>
---
 options/custom/desktops/niri/misc.nix  |  8 +++++++-
 options/custom/desktops/niri/rules.nix | 27 ++++++++++++++++++--------
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/options/custom/desktops/niri/misc.nix b/options/custom/desktops/niri/misc.nix
index a846e7f..c44f311 100644
--- a/options/custom/desktops/niri/misc.nix
+++ b/options/custom/desktops/niri/misc.nix
@@ -10,6 +10,9 @@ with lib; let
 
   audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
   bash = "${pkgs.bash}/bin/bash";
+  chromium = getExe hm.programs.chromium.package;
+  loupe = "${pkgs.loupe}/bin/loupe";
+  nautilus = "${pkgs.nautilus}/bin/nautilus";
   niri = "${config.programs.niri.package}/bin/niri";
   sway-audio-idle-inhibit = "${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit";
   wallpaper = "${config.home-manager.users.${config.custom.username}.home.file.".local/bin/wallpaper".source}";
@@ -52,8 +55,11 @@ in {
           spawn-at-startup =
             [
               {command = [audio "--init"];} # Enforce audio profile state
-              {command = [bash "-c" config.custom.menus.clipboard.clear];} # Clear clipboard history
+              {command = [bash "-c" config.custom.menus.clipboard.clear-silent];} # Clear clipboard history
               {command = [sway-audio-idle-inhibit];} # Inhibit while audio is playing
+              {command = [chromium];}
+              {command = [loupe];}
+              {command = [nautilus];}
             ]
             ++ optionals config.custom.wallpaper [
               {command = [wallpaper];}
diff --git a/options/custom/desktops/niri/rules.nix b/options/custom/desktops/niri/rules.nix
index 6bd5260..be7aa58 100644
--- a/options/custom/desktops/niri/rules.nix
+++ b/options/custom/desktops/niri/rules.nix
@@ -53,7 +53,14 @@ in {
             {
               # Startup
               #?? <= 60 secs after niri launches
-              matches = [{at-startup = true;}];
+              matches = [
+                {at-startup = true;}
+                {app-id = "^org\.gnome\.Loupe$";}
+                {app-id = "^org\.gnome\.Nautilus$";}
+              ];
+
+              open-focused = false;
+              open-on-workspace = "1";
             }
 
             {
@@ -76,7 +83,7 @@ in {
                 then 0.4
                 else 0.7;
 
-              #// open-on-workspace = "2";
+              open-on-workspace = "2";
             }
 
             {
@@ -101,7 +108,7 @@ in {
                 {app-id = "^obsidian$";}
               ];
 
-              #// open-on-workspace = "2";
+              open-on-workspace = "2";
             }
 
             {
@@ -120,20 +127,24 @@ in {
               ];
 
               default-column-width = {}; # Window-defined
-              #// open-on-workspace = "1";
+              open-on-workspace = "1";
               variable-refresh-rate = true;
             }
 
             {
               # Media
               matches = [
-                {app-id = "^org\.gnome\.Loupe$";}
+                {
+                  app-id = "^org\.gnome\.Loupe$";
+                  title = "wallpaper.png";
+                }
+
                 {app-id = "^Spotify$";}
                 {app-id = "^totem$";}
                 {app-id = "^YouTube Music$";}
               ];
 
-              #// open-on-workspace = "3";
+              open-on-workspace = "3";
             }
 
             {
@@ -144,7 +155,7 @@ in {
                 {app-id = "^ONLYOFFICE Desktop Editors$";}
               ];
 
-              #// open-on-workspace = "2";
+              open-on-workspace = "2";
             }
 
             (let
@@ -199,7 +210,7 @@ in {
               ];
 
               open-floating = false;
-              #// open-on-workspace = "1";
+              open-on-workspace = "1";
             }
 
             ### Overrides