# ./modules/users/psljr/hyprland.nix
# Configure hyprland for user psljr

{ config, pkgs, ... }:

{
  home-manager.users.psljr = { pkgs, ... }: {
    # Configure hyprland
    wayland.windowManager.hyprland = {
      enable = true;
      settings = {

        # Define variables
        "$mod" = "SUPER";
        "$primary_100" = "rgba(FF9955EE)";
        "$primary_200" = "rgba(EF7679EE)";
        "$primary_300" = "rgba(C26793EE)";
        "$primary_400" = "rgba(846294EE)";
        "$primary_500" = "rgba(4C587DEE)";
        "$primary_600" = "rgba(2F4858EE)";

        # Define auto-run applications
        exec-once=[
          "dunst" # Notification daemon
          "hypridle" # Idle daemon
          "hyprpaper" # Wallpaper
          "waybar" # Status bar
          "[workspace 1 silent] kitty"
          "[workspace 2 silent] kitty"
          "[workspace 2 silent] signal-desktop"
          "[workspace 3 silent] chromium"
        ];
        
        # Keybinds
        bind = [
          "$mod, R, exec, rofi -show drun"
          "$mod SHIFT, R, exec, rofi -show run"
          "$mod, T, exec, kitty"
          "$mod, F, exec, nautilus"
          "$mod, C, killactive,"
          "$mod, M, exec, rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot/logout\""
          "$mod, L, exec, hyprlock"
          ", PRINT, exec, hyprshot -m window"
          "$mod, PRINT, exec, hyprshot -m output"
          "$mod SHIFT, PRINT, exec, hyprshot -m region"
          
          "$mod, left, movefocus, l"
          "$mod, right, movefocus, r"
          "$mod, up, movefocus, u"
          "$mod, down, movefocus, d"

          "$mod, 1, workspace, 1"
          "$mod, 2, workspace, 2"
          "$mod, 3, workspace, 3"
          "$mod, 4, workspace, 4"
          "$mod, 5, workspace, 5"
          "$mod, 6, workspace, 6"
          "$mod, 7, workspace, 7"
          "$mod, 8, workspace, 8"
          "$mod, 9, workspace, 9"
          "$mod, 0, workspace, 10"

          "$mod SHIFT, 1, movetoworkspace, 1"
          "$mod SHIFT, 2, movetoworkspace, 2"
          "$mod SHIFT, 3, movetoworkspace, 3"
          "$mod SHIFT, 4, movetoworkspace, 4"
          "$mod SHIFT, 5, movetoworkspace, 5"
          "$mod SHIFT, 6, movetoworkspace, 6"
          "$mod SHIFT, 7, movetoworkspace, 7"
          "$mod SHIFT, 8, movetoworkspace, 8"
          "$mod SHIFT, 9, movetoworkspace, 9"
          "$mod SHIFT, 0, movetoworkspace, 10"

          "$mod, H, layoutmsg, preselect r"
          "$mod, V, layoutmsg, preselect d"
          "$mod SHIFT, right, resizeactive, 100 0"
          "$mod SHIFT, left, resizeactive, -100 0"
          
        ];

        # Mouse binds
        bindm = [
          "$mod, mouse:272, movewindow"
        ];

        # Multimedia binds
        bindel = [
          ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"
          ", XF86AudioLowerVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%-"
          ", XF86AudioMute, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ toggle"
          ", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
          ", XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+"
          ", XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%-"
        ];

        # Set window rules
        windowrule = [
          "suppressevent maximize, class:*"
          "nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
        ];

        input = {
          kb_layout = "us";
          follow_mouse = 1;
        };

        general = {
          gaps_in = 4;
          gaps_out = 8;
          border_size = 2;
          "col.active_border" = "$primary_100 $primary_300 45deg";
          "col.inactive_border" = "$primary_500";
          layout = "dwindle";
        };

        decoration = {
          rounding = 5;
          rounding_power = 2;

          blur = {
            enabled = true;
            size = 4;
            passes = 1;
          };
          
          dim_inactive = false;
          dim_strength = 0.25;

          shadow = {
            enabled = true;
            range = 4;
            render_power = 2;
            color = "rgba(1a1a1aee)";
          };
        };

        animations.enabled = true;

        dwindle = {
          pseudotile = "yes";
          preserve_split = "yes";
        };
      };
    };
  };
}
