From 19832c3a40d86a927090f6bc711dd913e8a89039 Mon Sep 17 00:00:00 2001
From: Zynh Ludwig <zynh0722@gmail.com>
Date: Thu, 20 Mar 2025 02:34:41 -0700
Subject: [PATCH] hyprland: working config

---
 hosts/llynx/home.nix             |   2 +
 hosts/snowhawk/configuration.nix |  13 ++
 modules/hyprland.nix             | 222 ++++++++++++++++++++++++++++++-
 3 files changed, 234 insertions(+), 3 deletions(-)

diff --git a/hosts/llynx/home.nix b/hosts/llynx/home.nix
index 8ff6696..56c9a04 100644
--- a/hosts/llynx/home.nix
+++ b/hosts/llynx/home.nix
@@ -22,6 +22,8 @@
     neovim.enable = true;
   };
 
+  wayland.windowManager.hyprland.settings.monitor = [ ",preferred,auto,auto" ];
+
   snowhawk.ssh = {
     enable = true;
     homeNetwork = true;
diff --git a/hosts/snowhawk/configuration.nix b/hosts/snowhawk/configuration.nix
index f27b02e..2c4979c 100644
--- a/hosts/snowhawk/configuration.nix
+++ b/hosts/snowhawk/configuration.nix
@@ -65,7 +65,19 @@
         snowhawk.hyprland = {
           enable = true;
           nvidia = true;
+          split-monitor-workspaces = true;
         };
+
+        home-manager.sharedModules = [{
+          wayland.windowManager.hyprland = {
+            settings = {
+              monitor = [
+                "DP-1, 1920x1080@144, 1920x0, 1"
+                "HDMI-A-1, 1920x1080@60, 0x0, 1"
+              ];
+            };
+          };
+        }];
       };
       plasma.configuration = {
         environment.etc."specialisation".text = "plasma";
@@ -167,6 +179,7 @@
 
   services.ratbagd.enable = true;
 
+  programs.gamescope.enable = true;
   programs.steam = {
     enable = true;
     remotePlay.openFirewall = true;
diff --git a/modules/hyprland.nix b/modules/hyprland.nix
index b1408c3..ffaffe3 100644
--- a/modules/hyprland.nix
+++ b/modules/hyprland.nix
@@ -7,6 +7,8 @@ in
   options.snowhawk.hyprland = {
     enable = lib.mkEnableOption "hyprland";
 
+    split-monitor-workspaces = lib.mkEnableOption "split-monitor-workspaces";
+
     nvidia = lib.mkEnableOption "hyprland nvidia tweaks";
   };
 
@@ -71,18 +73,232 @@ in
     # hyprland configuration
     {
       home-manager.sharedModules = [{
-        xdg.configFile."hypr/rose-pine.conf".text = builtins.readFile ../home/hypr/rose-pine.conf;
         wayland.windowManager.hyprland = {
           enable = true;
-          extraConfig = builtins.readFile ../home/hypr/hyprland.conf;
+          # extraConfig = builtins.readFile ../home/hypr/hyprland.conf;
+          settings = {
+            source = [ "${../home/hypr/rose-pine.conf}" ];
+
+            env = [
+              "XCURSOR_SIZE,24"
+              "HYPRCURSOR_SIZE,24"
+              "MOZ_ENABLE_WAYLAND,1"
+            ];
+
+            # TODO: Direct links
+            "$terminal" = "kitty";
+            "$fileManager" = "pcmanfm";
+            "$menu" = "wofi --show drun";
+
+            "$mainMod" = "SUPER";
+
+            general = {
+              gaps_in = 5;
+              gaps_out = 5;
+              border_size = 1;
+
+              "col.active_border" = "$foam $pine 45deg";
+              "col.inactive_border" = "$muted";
+
+              resize_on_border = true;
+
+              allow_tearing = false;
+
+              layout = "dwindle";
+            };
+
+            # https://wiki.hyprland.org/Configuring/Variables/#decoration
+            decoration = {
+              rounding = 5;
+              rounding_power = 2;
+
+              active_opacity = 1.0;
+              inactive_opacity = 1.0;
+
+              shadow = {
+                enabled = true;
+                range = 4;
+                render_power = 3;
+                color = "rgba(1a1a1aee)";
+              };
+
+              # https://wiki.hyprland.org/Configuring/Variables/#blur
+              blur = {
+                enabled = true;
+                size = 3;
+                passes = 1;
+
+                vibrancy = 0.1696;
+              };
+            };
+
+            # https://wiki.hyprland.org/Configuring/Variables/#animations
+            animations = {
+              enabled = "no,";
+
+              bezier = [ "easeOutQuint,0.23,1,0.32,1" "easeInOutCubic,0.65,0.05,0.36,1" "linear,0,0,1,1" "almostLinear,0.5,0.5,0.75,1.0" "quick,0.15,0,0.1,1" ];
+
+              # I need to tinker with these some more for llynx
+              # animation = global, 1, 10, default
+              # animation = border, 1, 5.39, easeOutQuint
+              # animation = windows, 1, 4.79, easeOutQuint
+              # animation = windowsIn, 1, 4.1, easeOutQuint, popin 87%
+              # animation = windowsOut, 1, 1.49, linear, popin 87%
+              # animation = windowsMove, 1, 4.79, easeOutQuint
+              # animation = fadeIn, 1, 1.73, almostLinear
+              # animation = fadeOut, 1, 1.46, almostLinear
+              # animation = fade, 1, 3.03, quick
+              # animation = layers, 1, 3.81, easeOutQuint
+              # animation = layersIn, 1, 4, easeOutQuint, fade
+              # animation = layersOut, 1, 1.5, linear, fade
+              # animation = fadeLayersIn, 1, 1.79, almostLinear
+              # animation = fadeLayersOut, 1, 1.39, almostLinear
+              # animation = workspaces, 1, 1.94, almostLinear, fade
+              # animation = workspacesIn, 1, 1.21, almostLinear, fade
+              # animation = workspacesOut, 1, 1.94, almostLinear, fade
+            };
+
+            # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
+            dwindle = {
+              pseudotile = true;
+              preserve_split = true;
+            };
+
+            # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
+            master = {
+              new_status = "master";
+            };
+
+            # https://wiki.hyprland.org/Configuring/Variables/#misc
+            misc = {
+              force_default_wallpaper = -1;
+              disable_hyprland_logo = false;
+            };
+
+            cursor = {
+              inactive_timeout = 5;
+            };
+
+            # https://wiki.hyprland.org/Configuring/Variables/#input
+            input = {
+              kb_layout = "us";
+              kb_variant = "";
+              kb_model = "";
+              kb_options = "";
+              kb_rules = "";
+
+              follow_mouse = 1;
+              sensitivity = 0;
+
+              touchpad = {
+                natural_scroll = true;
+                clickfinger_behavior = true;
+              };
+            };
+
+            # https://wiki.hyprland.org/Configuring/Variables/#gestures
+            gestures = {
+              workspace_swipe = true;
+              workspace_swipe_distance = 50;
+            };
+
+            plugin = {
+              split-monitor-workspaces = lib.mkIf cfg.split-monitor-workspaces {
+                count = 10;
+                keep_focused = 10;
+                enable_notifications = 1;
+                enable_persistent_workspaces = 0;
+              };
+            };
+
+            windowrulev2 = [
+              # Ignore maximize requests from apps. You'll probably like this.
+              "suppressevent maximize, class:.*"
+              # Fix some dragging issues with XWayland
+              "nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
+            ];
+
+            bindm = [
+              # Move/resize windows with mainMod + LMB/RMB and dragging
+              "$mainMod, mouse:272, movewindow"
+              "$mainMod, mouse:273, resizewindow"
+            ];
+
+            bindel = [
+              # Laptop multimedia keys for volume and LCD brightness
+              ",XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"
+              ",XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"
+              ",XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
+              ",XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
+              ",XF86MonBrightnessUp, exec, brightnessctl s 10%+"
+              ",XF86MonBrightnessDown, exec, brightnessctl s 10%-"
+            ];
+
+            bindl = [
+              # Requires playerctl
+              ", XF86AudioNext, exec, playerctl next"
+              ", XF86AudioPause, exec, playerctl play-pause"
+              ", XF86AudioPlay, exec, playerctl play-pause"
+              ", XF86AudioPrev, exec, playerctl previous"
+            ];
+
+            bind = [
+              "$mainMod, Q, exec, $terminal"
+              "$mainMod, C, killactive,"
+              "$mainMod, M, exit,"
+              "$mainMod, E, exec, $fileManager"
+              "$mainMod, V, togglefloating,"
+              "$mainMod, R, exec, $menu"
+              "$mainMod, P, pseudo, # dwindle"
+              "$mainMod, J, togglesplit, # dwindle"
+
+              "$mainMod SHIFT, minus, exec, bash -c \"XDG_CURRENT_DESKTOP=sway flameshot gui\""
+              "$mainMod, n, exec, swaync-client -t"
+
+              # moving focus
+              "$mainMod, left, movefocus, l"
+              "$mainMod, right, movefocus, r"
+              "$mainMod, up, movefocus, u"
+              "$mainMod, down, movefocus, d"
+
+              # scratchpad
+              "$mainMod, S, togglespecialworkspace, magic"
+              "$mainMod SHIFT, S, movetoworkspace, special:magic"
+            ] ++ (
+              # workspaces
+              # binds $mod + [shift +] {1..9} to [move to] workspace {1..9}
+              builtins.concatLists (builtins.genList
+                (i:
+                  let ws = i + 1;
+                  in [
+                    "$mainMod, code:1${toString i}, ${lib.optionalString cfg.split-monitor-workspaces "split-"}workspace, ${toString ws}"
+                    "$mainMod SHIFT, code:1${toString i}, ${lib.optionalString cfg.split-monitor-workspaces "split-"}movetoworkspace, ${toString ws}"
+                  ]
+                )
+                9)
+            );
+          };
+
           package = null;
           portalPackage = null;
+        };
+      }];
+    }
+
+    # split-monitor-workspaces
+    (lib.mkIf cfg.split-monitor-workspaces {
+      home-manager.sharedModules = [{
+        wayland.windowManager.hyprland = {
+          settings.bind = [
+            "$mainMod SHIFT, comma, split-changemonitor, -1"
+            "$mainMod SHIFT, period, split-changemonitor, +1"
+          ];
           plugins = [
             inputs.split-monitor-workspaces.packages.${pkgs.system}.split-monitor-workspaces
           ];
         };
       }];
-    }
+    })
 
     # useful desktop stuff
     {