{config, pkgs, pkgs-unstable, inputs, host, user, nvidia, rice, lib, ... }:
let
  animation-speed = "5";
  transparency = builtins.toString rice.transparency;
  monitors = {
    xps = {
      main = {
        name = "eDP-1";
        resolution = "1920x1200";
        position = "0x0";
        scale = "1.0";
      };
      second = {
        name = "DP-3";
        resolution = "1920x1080";
        position = "1920x0";
        scale = "1.0";
      };
    };
    north = {
      main = {
        name = "DP-4";
        resolution = "2560x1440";
        position = "1920x0";
        scale = "1.0";
      };
      left = {
        name = "HDMI-A-2";
        resolution = "1920x1080";
        position = "0x360";
        scale = "1.0";
      };
      # right = {
      #   name = "HDMI-A-2";
      #   resolution = "1920x1080";
      #   position = "4480x360";
      #   scale = "1.0";
      # };
    };
    ace = {
      main = {
        name = "HDMI-A-1";
        resolution = "3840x2160";
        position = "0x0";
        scale = "2.0";
      };
    };
  };
in
lib.mkIf (user != "tv")
{
  home.packages = (with pkgs; [
    # hyprland itself is a system package
    hyprland-protocols
    hyprlock
    hypridle
    hyprcursor

    grim
    slurp

  # ]) ++ (with pkgs-unstable; [
    
  ]) ++ (with inputs; [
    hyprswitch.packages.x86_64-linux.default
  ]);
  

  wayland.windowManager.hyprland = {
    enable = true;
    # package = pkgs-unstable.hyprland;
    package = pkgs.hyprland;
    # package = inputs.hyprland.packages.${pkgs.system}.hyprland;
    xwayland.enable = true;
    systemd.enable = true;
    plugins = [
      # inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo
      # inputs.hyprfocus.packages.${pkgs.system}.hyprfocus
      # inputs.hycov.packages.${pkgs.system}.hycov
      # inputs.Hyprspace.packages.${pkgs.system}.Hyprspace
    ];

    settings = {
      monitor =
        if host == "NxXPS" then (with monitors.xps; [
          "${main.name}, ${main.resolution}, ${main.position}, ${main.scale}"
          "${second.name}, ${second.resolution}, ${second.position}, ${second.scale}"
        ]) else (if host == "NxNORTH" then (with monitors.north; [
          "${main.name}, ${main.resolution}, ${main.position}, ${main.scale}"
          "${left.name}, ${left.resolution}, ${left.position}, ${left.scale}"
          # "${right.name}, ${right.resolution}, ${right.position}, ${right.scale}"
        ]) else ( with monitors.ace; [
          "${main.name}, ${main.resolution}, ${main.position}, ${main.scale}"
        ]));

      workspace =
        let
          d1 = if host == "NxXPS" then monitors.xps.main.name else (if host == "NxNORTH" then monitors.north.main.name else monitors.ace.main.name);
          d2 = if host == "NxXPS" then monitors.xps.second.name else (if host == "NxNORTH" then monitors.north.left.name else monitors.ace.main.name);
          d3 = if host == "NxXPS" then monitors.xps.main.name else (if host == "NxNORTH" then monitors.north.main.name else monitors.ace.main.name);
          # d3 = if host == "NxXPS" then monitors.xps.main.name else (if host == "NxNORTH" then monitors.north.right.name else monitors.ace.main.name);
         compact = "gapsin:0, gapsout:0, bordersize:1, rounding:false";
        in
        [
          "11, monitor:${d1}, default:true"
          "12, monitor:${d1}"
          "13, monitor:${d1}"
          "14, monitor:${d1}"
          "15, monitor:${d1}"
          "16, monitor:${d1}"
          "17, monitor:${d1}"
          "18, monitor:${d1}"
          "19, monitor:${d1}"
          "10, monitor:${d1}, ${compact}"
          "100, monitor:${d1}, ${compact}"
          "21, monitor:${d2}, default:true, ${compact}"
          "22, monitor:${d2}"
          "23, monitor:${d2}"
          "24, monitor:${d2}"
          "25, monitor:${d2}"
          "26, monitor:${d2}"
          "27, monitor:${d2}"
          "28, monitor:${d2}"
          "29, monitor:${d2}"
          "20, monitor:${d2}"
          "31, monitor:${d3}, default:${let x = if host == "NxNORTH" then "true" else "false"; in x}"
          "32, monitor:${d3}"
          "33, monitor:${d3}"
          "34, monitor:${d3}"
          "35, monitor:${d3}"
          "36, monitor:${d3}"
          "37, monitor:${d3}"
          "38, monitor:${d3}"
          "39, monitor:${d3}"
          "30, monitor:${d3}, ${compact}"
        ];

      # "device:logitech-wireless-mouse-mx-master-1" = {
      #   sensitivity = -0.2;
      # };


      env = if nvidia.enable == true then [
        "LIBVA_DRIVER_NAME,nvidia"
        "XDG_SESSION_TYPE,wayland"
        "GBM_BACKEND,nvidia-drm"
        "__GLX_VENDOR_LIBRARY_NAME,nvidia"
        "WLR_NO_HARDWARE_CURSORS,1"
        "HYPRCURSOR_THEME,${config.gtk.cursorTheme.name}"
        "HYPRCURSOR_SIZE,${toString config.gtk.cursorTheme.size}"
      ] else [];

      input = {
        sensitivity = 0.1;
        kb_layout = "de";
        follow_mouse = "1";
        touchpad = {
          natural_scroll = true;
          scroll_factor = "0.9";
        };
      };

      general = {
        gaps_in = builtins.div rice.gap-size 2;
        gaps_out = rice.gap-size;
        border_size = rice.border-width;
        "col.active_border" = "rgba(${rice.lib.nohash rice.color.border}ff) rgba(${rice.lib.nohash rice.color.border2}ff) 90deg";
        "col.inactive_border" = "rgba(${rice.lib.nohash rice.color.background}ff) rgba(${rice.lib.nohash rice.color.border2}ff) 90deg";

        # cursor_inactive_timeout = 10;

        layout = "dwindle";
        # layout = "master";
        resize_on_border = false;
      };

      decoration = {
        rounding = rice.rounding;
        drop_shadow = false;
        shadow_range = "20";
        shadow_offset = "0 0";
        shadow_render_power = "4";
        "col.shadow" = "rgba(${rice.lib.nohash rice.color.red.base}ff)";
        "col.shadow_inactive" = "rgba(${rice.lib.nohash rice.color.black.base}ff)";

        active_opacity = "1.0";
        inactive_opacity = "1.0";
        fullscreen_opacity = "1.0";

        dim_inactive = false;
        dim_strength = "0.2";
        dim_around = "0.8";

        blur = {
          enabled = true;
          size = "3";
          passes = "2";
          xray = false;
          vibrancy = 0.5;
          ignore_opacity = true;
        };
      };

      animations = {
        enabled = true;
        # bezier = "myBezier, 0.01, 0.9, 0.1, 1.0"; #o
        # bezier = "myBezier, 0.83, 0, 0.17, 1"; # io
        bezier = "myBezier, 0.33, 1, 0.68, 1";
        animation = let direction = if host == "NxXPS" then "slide" else "slidevert"; in [
          "windows, 1, ${animation-speed}, myBezier, slide"
          "border, 1, ${animation-speed}, myBezier"
          "fade, 1, ${animation-speed}, myBezier"
          "workspaces, 1, ${animation-speed}, myBezier, ${direction}"
        ];
      };

      gestures = {
        workspace_swipe = true;
        workspace_swipe_fingers = "4";
        workspace_swipe_distance = "300";
        workspace_swipe_invert = true;
        workspace_swipe_min_speed_to_force = "30";
        workspace_swipe_cancel_ratio = "0.5";
        workspace_swipe_create_new = false;
        workspace_swipe_direction_lock = false;
        workspace_swipe_direction_lock_threshold = "10";
        workspace_swipe_forever = true;
        workspace_swipe_use_r = false;
      };

      dwindle = {
        preserve_split = true; # you probably want this
        no_gaps_when_only = false;
      };

      # master = {
      # };

      misc = {
        disable_hyprland_logo = true;
        animate_mouse_windowdragging = false;
        enable_swallow = true;
      };

      exec-once = [
        "waybar"
        "swww-daemon"
        "hyprland-autoname-workspaces"
        "/usr/lib/polkit-kde-authentication-agent-1 "
        "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
        "syncthing -no-browser"
        "mako"
        "fcitx5"
        # "ibus engine xkb:de::deu"
        "libinput-gestures"
        # "hyprswitch --daemon"
      ];

      windowrulev2 = [
        "opacity ${transparency},class:^(com.chatterino.*)$"
        "opacity ${transparency},class:^(chatterino)$"
        "bordercolor rgba(${rice.lib.nohash rice.color.magenta.bright}ff), pinned:1"
      ];

      windowrule = [
        # "opacity ${transparency}, firefox"
        "opacity ${transparency}, code-oss"
        "opacity ${transparency}, VSCodium"
        "opacity ${transparency}, Code"
        "opacity ${transparency}, sent"
        "opacity ${transparency}, neovide"
        "opacity ${transparency}, obsidian"
        "opacity ${transparency}, zathura"
        # "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Alacritty"
        # "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Kitty"
        "opacity ${transparency}, discord"
        "opacity ${transparency}, vesktop"
        "opacity ${transparency}, Element"
        "opacity ${transparency}, thunderbird"
        "opacity ${transparency}, lutris"
        "opacity ${transparency}, element"
        "opacity ${transparency}, ^([sS]potify)$"
        "opacity ${transparency}, virt-manager"
        "opacity ${transparency}, thunar"
        "opacity ${transparency}, title:^(wlogout)$"
        "opaque, title:^(GNU Image Manipulation Program)$"
        "float, title:^(Picture-in-Picture)$"
        "float, title:^(Ibus-ui.*)$"
        "float, ^(ibus-ui.*)$"
        "float, ^(ibus-ui-gtk3)$"
        "float, title:^(Ibus-ui-gtk3)$"
        "pin, title:^(Picture-in-Picture)$"
        "float, org.kde.polkit-kde-authentication-agent-1"
        "float, title:^(wlogout)$"
        "float, imv"
        "float, title:^(Page Info — .*)$"
        "float, title:^(Compact folders)$"
        "tile, sent"
        "fullscreen, wlogout"
        "workspace 14, lutris"
        "workspace 100, title:^(Apex Legends)$"
        "workspace 100, ^(cyberpunk2077.exe)$"
        "workspace 100, title:^(No Man.s Sky)$"
        "workspace 100, gamescope"
      ];


      layerrule = [
        "blur,waybar"
        "dimaround,rofi"
        "blur,rofi"
        "xray,rofi"
      ];


      # d8888b. d888888b d8b   db d8888b. .d8888.
      # 88  '8D   '88'   888o  88 88  '8D 88'  YP
      # 88oooY'    88    88V8o 88 88   88 '8bo.
      # 88''Yb.    88    88 V8o88 88   88   'Y8b.
      # 88   8D   .88.   88  V888 88  .8D db   8D
      # Y8888P' Y888888P VP   V8P Y8888D' '8888Y'

      ###########################################################################
      ## ROW 0:
      bind = [
        "SUPER SHIFT, Escape, exit, "
        "SUPER,       F1, workspace,       100"
        "SUPER SHIFT, F1, movetoworkspace, 100"
        # "SUPER,       F2,"
        "SUPER,       F3, toggleopaque"
        # "SUPER,       F4,"
        "SUPER,       F5, exec, nx_gcal_event force-lookup"
        "SUPER SHIFT, F5, exec, nx_gcal_event reauthenticate"
        # "SUPER,       F6,"
        ''SUPER,       F8, exec, find ~/Pictures/wallpapers/* -type f -not -path "~/Pictures/wallpapers/.git/*" | sort -R | head -n 1 | xargs swww img --transition-type wipe --transition-angle 60 --transition-step 120 --transition-fps 120''
        "SUPER,       F9, exec, change_colors_json $(swww query | sed -n 1p | sed -e 's-.*image: --g') && nh home switch" 
        # "SUPER,       F10, hyprload,update"
        "SUPER,       F11, exec, waybar"
        "SUPER SHIFT, F11, exec, pkill waybar "
        "SUPER,       F12, exec, hyprland-autoname-workspaces"
        "SUPER SHIFT, F12, exec, pkill -9 hyprland-autoname-workspaces  "

        ###########################################################################
        ## ROW 1:

        # "SUPER,       ^, "
        "SUPER,       1, workspace,       11"
        "SUPER SHIFT, 1, movetoworkspace, 11"
        "SUPER,       2, workspace,       12"
        "SUPER SHIFT, 2, movetoworkspace, 12"
        "SUPER,       3, workspace,       13"
        "SUPER SHIFT, 3, movetoworkspace, 13"
        "SUPER,       4, workspace,       14"
        "SUPER SHIFT, 4, movetoworkspace, 14"
        "SUPER,       5, workspace,       15"
        "SUPER SHIFT, 5, movetoworkspace, 15"
        "SUPER,       6, workspace,       16"
        "SUPER SHIFT, 6, movetoworkspace, 16"
        "SUPER,       7, workspace,       17"
        "SUPER SHIFT, 7, movetoworkspace, 17"
        "SUPER,       8, workspace,       18"
        "SUPER SHIFT, 8, movetoworkspace, 18"
        "SUPER,       9, workspace,       19"
        "SUPER SHIFT, 9, movetoworkspace, 19"
        "SUPER,       0, workspace,       10"
        "SUPER SHIFT, 0, movetoworkspace, 10"

        # "SUPER,       ß,"
        # "SUPER,       ´,"
        # "SUPER,       Backspace,"

        ###########################################################################
        ## ROW 2:

        #bind = SUPER,       TAB, hycov:toggleoverview
        # "SUPER,       TAB, overview:toggle"
        # "SUPER,       TAB, hyprexpo:expo, toggle"
        "ALT,         TAB, focuscurrentorlast"
        # "SUPER,       TAB, exec, hyprswitch --daemon"
        "SUPER,       Q, killactive"
        "SUPER,       W, exec, waybar_mode set '󰈹 '"
        "SUPER,       W, submap, browserSM "
        "SUPER,       E, exec, element-desktop"
        "SUPER,       R, exec, rofi -show drun"
        # "SUPER,       T, exec, alacritty"
        # "SUPER SHIFT, T, exec, alacritty -e sh -c "ssh nxace""
        "SUPER,       T, exec, kitty"
        "SUPER SHIFT, T, exec, kitty -e sh -c 'ssh nxace'"
        # "SUPER,       Z, "
        "SUPER,       U, exec, thunderbird "
        "SUPER,       I, exec, kitty -e fish -c 'hx ~/nix-dots/ && fish'"
        "SUPER SHIFT, I, exec, kitty -e fish -c 'nh home switch || read'"
        "SUPER CTRL,  I, exec, kitty -e fish -c 'nh os switch || read'"
        "SUPER,       O, exec, obsidian "
        "SUPER,       P, pin "
        # "SUPER,       Ü,"
        # "SUPER,       +,"
        # "SUPER,       Enter,"

        ###########################################################################
        ## ROW 3:

        "SUPER,       A, execr, waybar_mode set ' 󰹑 '"
        "SUPER,       A, submap, scrL"
        "SUPER,       S, exec, spotify"
        "SUPER,       D, exec, vesktop"
        "SUPER,       F, fullscreen"
        # "SUPER,       G,"
        "SUPER,       H, movefocus, l"
        "SUPER,       J, movefocus, d"
        "SUPER,       K, movefocus, u"
        "SUPER,       L, movefocus, r"
        # "SUPER,       Ö,"
        # "SUPER,       Ä,"
        # "SUPER,       #,"

        ###########################################################################
        ## ROW 4:

        # "SUPER,       <, overview:toggle"
        "SUPER,       Y, execr, waybar_mode set '󰹑 '"
        "SUPER,       Y, submap, scrR"
        "SUPER,       X, exec, pkill wlogout || wlogout --protocol layer-shell -b 3"
        # "SUPER,       C, exec, /home/nx2/scripts/quickconfig/quickconfig.sh "
        "SUPER,       C, exec, chatterino"
        "SUPER,       V, togglefloating, "
        "SUPER,       B, exec, bitwarden"
        "SUPER,       N, togglesplit"
        # "SUPER,       M, exec, /home/nx2/scripts/meme-full-screen/meme-full-screen.sh "
        # "SUPER,       comma, exec, /home/nx2/scripts/change-language.sh"
        "SUPER,       ., exec, echo key x:Prior | dotool"
        "SUPER,       -, exec, echo key x:Next | dotool"

        ###########################################################################
        ## ROW 5:

        # bindr = SUPER, Ctrl, exec, # ??
        # bindr = SUPERALT, Alt_L, exec, 
        "SUPER,            Space, cyclenext"
        "SUPER SHIFT,      Space, swapnext"
        # "SUPER,      , "
        # "SUPER,      , "
        # "SUPER,      AppsKey, # ? "
        #

        ###########################################################################
        ## ARROW KEYS:

        "SUPER, left, movefocus, l"
        # "SUPER SHIFT, left, split-changemonitor, prev"
        "SUPER, right, movefocus, r"
        "SUPER, up, movefocus, u"
        # "SUPER SHIFT, right, split-changemonitor, next"
        "SUPER, down, movefocus, d"

        ###########################################################################
        ## MEGA KEYS:

        ''     , Print, exec, grim -g "$(slurp)"''
        # "SUPER, Next, resizeactive, 5% 5%" # binde
        # "SUPER, Prior, resizeactive, -5% -5%" # binde

        ###########################################################################
        ## FN KEYS:

        ",XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"
        ",XF86AudioLowerVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"
        ",XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
        ",XF86AudioPlay, exec, playerctl play-pause"
        ",XF86AudioPrev, exec, playerctl previous"
        ",XF86AudioNext, exec, playerctl next"
        ",XF86MonBrightnessUp, exec, brightnessctl s '5%+'"
        ",XF86MonBrightnessDown, exec, brightnessctl s '5%-'"

        ###########################################################################
        ## MOUSE:

        "SUPER, mouse_down, workspace, e+1"
        "SUPER, mouse_up, workspace, e-1"
      ];


      bindm = [
        "SUPER, mouse:272, movewindow"
        "SUPER, mouse:273, resizewindow"
      ];

      bindl = [
        # ",switch:on:Lid Switch, exec, hyprlock &"
      ];
      binde = [
        # "SUPER, TAB, exec, hyprswitch --daemon --do-initial-execute"
        "SUPER, Next, resizeactive, 10% 10%" 
        "SUPER, Prior, resizeactive, -10% -10%" 
      ];
    };



    # .d8888. db    db d8888b. 88b  d88   d8b   d88888b. .d8888.
    # 88'  YP 88    88 88  '8D 88YbdP88  dP'Yb  88'  '8b 88'  YP
    # '8bo.   88    88 88oooY' 88 YP 88 d8. .8b 88.  .8P '8bo.
    #   'Y8b. 88    88 88''Yb. 88    88 8888888 888888P'   'Y8b.
    # db   8D 88.  .88 88   8D 88    88 88' '88 88       db   8D
    # '8888Y' 'Y8888P' Y8888P' YP    YP 88   YP YP       '8888Y'
    extraConfig = ''
      submap = browserSM
      bind = , W, exec, waybar_mode unset
      bind = , W, exec, hyprctl dispatch exec firefox 
      bind = , W, submap, reset

      bind = , Y, exec, waybar_mode unset 
      bind = , Y, exec, firefox https://youtube.com 
      bind = , Y, submap, reset

      bind = , T, exec, waybar_mode unset
      bind = , T, exec,  hyprctl dispatch exec firefox https://twitch.tv
      bind = , T, submap, reset

      bind = , R, exec, waybar_mode unset
      bind = , R, exec,  firefox https://reddit.com 
      bind = , R, submap, reset

      bind = , C, exec, waybar_mode unset
      bind = , C, exec,  firefox https://calendar.google.com 
      bind = , C, submap, reset

      bind = , Ü, exec, waybar_mode unset
      bind = , Ü, exec,  firefox https://translate.google.com 
      bind = , Ü, submap, reset

      bind = , N, exec, waybar_mode unset
      bind = , N, exec,  firefox https://Netflix.com 
      bind = , N, submap, reset

      bind = , A, exec, waybar_mode unset
      bind = , A, exec,  firefox https://www.amazon.de/b?node=3010075031&ref_=nav_ya_signin 
      bind = , A, submap, reset

      bind = , D, exec, waybar_mode unset
      bind = , D, exec,  firefox https://www.disneyplus.com/home 
      bind = , D, submap, reset

      bind = , H, exec, waybar_mode unset
      bind = , H, exec,  firefox https://www.hs-mittweida.de 
      bind = , H, submap, reset

      bind = , X, exec, waybar_mode unset
      bind = , X, exec,  firefox https://nx2.site 
      bind = , X, submap, reset

      bind = , L, exec, waybar_mode unset
      bind = , L, exec,  firefox https://feddit.de
      bind = , L, submap, reset

      bind = , I, exec, waybar_mode unset
      bind = , I, exec,  firefox https://www.imdb.com
      bind = , I, submap, reset

      bind = , M, exec, waybar_mode unset
      bind = , M, exec,  firefox https://ieji.de/home
      bind = , M, submap, reset

      bind = , S, exec, waybar_mode unset
      bind = , S, exec,  firefox 127.0.0.1:8384/
      bind = , S, submap, reset

      bind = , Escape, exec, waybar_mode unset
      bind = , Escape, submap, reset
      submap = reset


      submap = scrL
      bind =      ,       1, execr, waybar_mode unset
      bind =      ,       1, workspace,       21
      bind =      ,       1, submap, reset
      bind = SUPER,       1, execr, waybar_mode unset
      bind = SUPER,       1, workspace,       21
      bind = SUPER,       1, submap, reset
      bind = SUPER SHIFT, 1, execr, waybar_mode unset
      bind = SUPER SHIFT, 1, movetoworkspace, 21
      bind = SUPER SHIFT, 1, submap, reset

      bind =      ,       2, execr, waybar_mode unset
      bind =      ,       2, workspace,       22
      bind =      ,       2, submap, reset
      bind = SUPER,       2, execr, waybar_mode unset
      bind = SUPER,       2, workspace,       22
      bind = SUPER,       2, submap, reset
      bind = SUPER SHIFT, 2, execr, waybar_mode unset
      bind = SUPER SHIFT, 2, movetoworkspace, 22
      bind = SUPER SHIFT, 2, submap, reset

      bind =      ,       3, execr, waybar_mode unset
      bind =      ,       3, workspace,       23
      bind =      ,       3, submap, reset
      bind = SUPER,       3, execr, waybar_mode unset
      bind = SUPER,       3, workspace,       23
      bind = SUPER,       3, submap, reset
      bind = SUPER SHIFT, 3, execr, waybar_mode unset
      bind = SUPER SHIFT, 3, movetoworkspace, 23
      bind = SUPER SHIFT, 3, submap, reset

      bind =      ,       4, execr, waybar_mode unset
      bind =      ,       4, workspace,       24
      bind =      ,       4, submap, reset
      bind = SUPER,       4, execr, waybar_mode unset
      bind = SUPER,       4, workspace,       24
      bind = SUPER,       4, submap, reset
      bind = SUPER SHIFT, 4, execr, waybar_mode unset
      bind = SUPER SHIFT, 4, movetoworkspace, 24
      bind = SUPER SHIFT, 4, submap, reset

      bind =      ,       5, execr, waybar_mode unset
      bind =      ,       5, workspace,       25
      bind =      ,       5, submap, reset
      bind = SUPER,       5, execr, waybar_mode unset
      bind = SUPER,       5, workspace,       25
      bind = SUPER,       5, submap, reset
      bind = SUPER SHIFT, 5, execr, waybar_mode unset
      bind = SUPER SHIFT, 5, movetoworkspace, 25
      bind = SUPER SHIFT, 5, submap, reset

      bind =      ,       6, execr, waybar_mode unset
      bind =      ,       6, workspace,       26
      bind =      ,       6, submap, reset
      bind = SUPER,       6, execr, waybar_mode unset
      bind = SUPER,       6, workspace,       26
      bind = SUPER,       6, submap, reset
      bind = SUPER SHIFT, 6, execr, waybar_mode unset
      bind = SUPER SHIFT, 6, movetoworkspace, 26
      bind = SUPER SHIFT, 6, submap, reset

      bind =      ,       7, execr, waybar_mode unset
      bind =      ,       7, workspace,       27
      bind =      ,       7, submap, reset
      bind = SUPER,       7, execr, waybar_mode unset
      bind = SUPER,       7, workspace,       27
      bind = SUPER,       7, submap, reset
      bind = SUPER SHIFT, 7, execr, waybar_mode unset
      bind = SUPER SHIFT, 7, movetoworkspace, 27
      bind = SUPER SHIFT, 7, submap, reset

      bind =      ,       8, execr, waybar_mode unset
      bind =      ,       8, workspace,       28
      bind =      ,       8, submap, reset
      bind = SUPER,       8, execr, waybar_mode unset
      bind = SUPER,       8, workspace,       28
      bind = SUPER,       8, submap, reset
      bind = SUPER SHIFT, 8, execr, waybar_mode unset
      bind = SUPER SHIFT, 8, movetoworkspace, 28
      bind = SUPER SHIFT, 8, submap, reset

      bind =      ,       9, execr, waybar_mode unset
      bind =      ,       9, workspace,       29
      bind =      ,       9, submap, reset
      bind = SUPER,       9, execr, waybar_mode unset
      bind = SUPER,       9, workspace,       29
      bind = SUPER,       9, submap, reset
      bind = SUPER SHIFT, 9, execr, waybar_mode unset
      bind = SUPER SHIFT, 9, movetoworkspace, 29
      bind = SUPER SHIFT, 9, submap, reset

      bind =      ,       0, execr, waybar_mode unset
      bind =      ,       0, workspace,       20
      bind =      ,       0, submap, reset
      bind = SUPER,       0, execr, waybar_mode unset
      bind = SUPER,       0, workspace,       20
      bind = SUPER,       0, submap, reset
      bind = SUPER SHIFT, 0, execr, waybar_mode unset
      bind = SUPER SHIFT, 0, movetoworkspace, 20
      bind = SUPER SHIFT, 0, submap, reset


      bind = , A, execr, waybar_mode unset
      bind = , A, submap, reset
      bind = , Escape, execr, waybar_mode unset
      bind = , Escape, submap, reset
      submap = reset


      submap = scrR
      bind =      ,       1, execr, waybar_mode unset
      bind =      ,       1, workspace,       31
      bind =      ,       1, submap, reset
      bind = SUPER,       1, execr, waybar_mode unset
      bind = SUPER,       1, workspace,       31
      bind = SUPER,       1, submap, reset
      bind = SUPER SHIFT, 1, execr, waybar_mode unset
      bind = SUPER SHIFT, 1, movetoworkspace, 31
      bind = SUPER SHIFT, 1, submap, reset

      bind =      ,       2, execr, waybar_mode unset
      bind =      ,       2, workspace,       32
      bind =      ,       2, submap, reset
      bind = SUPER,       2, execr, waybar_mode unset
      bind = SUPER,       2, workspace,       32
      bind = SUPER,       2, submap, reset
      bind = SUPER SHIFT, 2, execr, waybar_mode unset
      bind = SUPER SHIFT, 2, movetoworkspace, 32
      bind = SUPER SHIFT, 2, submap, reset

      bind =      ,       3, execr, waybar_mode unset
      bind =      ,       3, workspace,       33
      bind =      ,       3, submap, reset
      bind = SUPER,       3, execr, waybar_mode unset
      bind = SUPER,       3, workspace,       33
      bind = SUPER,       3, submap, reset
      bind = SUPER SHIFT, 3, execr, waybar_mode unset
      bind = SUPER SHIFT, 3, movetoworkspace, 33
      bind = SUPER SHIFT, 3, submap, reset

      bind =      ,       4, execr, waybar_mode unset
      bind =      ,       4, workspace,       34
      bind =      ,       4, submap, reset
      bind = SUPER,       4, execr, waybar_mode unset
      bind = SUPER,       4, workspace,       34
      bind = SUPER,       4, submap, reset
      bind = SUPER SHIFT, 4, execr, waybar_mode unset
      bind = SUPER SHIFT, 4, movetoworkspace, 34
      bind = SUPER SHIFT, 4, submap, reset

      bind =      ,       5, execr, waybar_mode unset
      bind =      ,       5, workspace,       35
      bind =      ,       5, submap, reset
      bind = SUPER,       5, execr, waybar_mode unset
      bind = SUPER,       5, workspace,       35
      bind = SUPER,       5, submap, reset
      bind = SUPER SHIFT, 5, execr, waybar_mode unset
      bind = SUPER SHIFT, 5, movetoworkspace, 35
      bind = SUPER SHIFT, 5, submap, reset

      bind =      ,       6, execr, waybar_mode unset
      bind =      ,       6, workspace,       36
      bind =      ,       6, submap, reset
      bind = SUPER,       6, execr, waybar_mode unset
      bind = SUPER,       6, workspace,       36
      bind = SUPER,       6, submap, reset
      bind = SUPER SHIFT, 6, execr, waybar_mode unset
      bind = SUPER SHIFT, 6, movetoworkspace, 36
      bind = SUPER SHIFT, 6, submap, reset

      bind =      ,       7, execr, waybar_mode unset
      bind =      ,       7, workspace,       37
      bind =      ,       7, submap, reset
      bind = SUPER,       7, execr, waybar_mode unset
      bind = SUPER,       7, workspace,       37
      bind = SUPER,       7, submap, reset
      bind = SUPER SHIFT, 7, execr, waybar_mode unset
      bind = SUPER SHIFT, 7, movetoworkspace, 37
      bind = SUPER SHIFT, 7, submap, reset

      bind =      ,       8, execr, waybar_mode unset
      bind =      ,       8, workspace,       38
      bind =      ,       8, submap, reset
      bind = SUPER,       8, execr, waybar_mode unset
      bind = SUPER,       8, workspace,       38
      bind = SUPER,       8, submap, reset
      bind = SUPER SHIFT, 8, execr, waybar_mode unset
      bind = SUPER SHIFT, 8, movetoworkspace, 38
      bind = SUPER SHIFT, 8, submap, reset

      bind =      ,       9, execr, waybar_mode unset
      bind =      ,       9, workspace,       39
      bind =      ,       9, submap, reset
      bind = SUPER,       9, execr, waybar_mode unset
      bind = SUPER,       9, workspace,       39
      bind = SUPER,       9, submap, reset
      bind = SUPER SHIFT, 9, execr, waybar_mode unset
      bind = SUPER SHIFT, 9, movetoworkspace, 39
      bind = SUPER SHIFT, 9, submap, reset

      bind =      ,       0, execr, waybar_mode unset
      bind =      ,       0, workspace,       30
      bind =      ,       0, submap, reset
      bind = SUPER,       0, execr, waybar_mode unset
      bind = SUPER,       0, workspace,       30
      bind = SUPER,       0, submap, reset
      bind = SUPER SHIFT, 0, execr, waybar_mode unset
      bind = SUPER SHIFT, 0, movetoworkspace, 30
      bind = SUPER SHIFT, 0, submap, reset

      bind = , Y, execr, waybar_mode unset
      bind = , Y, submap, reset
      bind = , Escape, execr, waybar_mode unset
      bind = , Escape, submap, reset
      submap = reset




      plugin {
          hyprexpo {
              columns = 5
              gap_size = ${builtins.toString rice.gap-size}
              bg_col = rgb(${builtins.substring 1 6 rice.color.background})
              workspace_method = first 10 # [center/first] [workspace] e.g. first 1 or center m+1

              enable_gesture = false # laptop touchpad, 4 fingers
              gesture_distance = 300 # how far is the "max"
              gesture_positive = true # positive = swipe down. Negative = swipe up.
          }
      }


      plugin {
          overview {
              panelColor = rgba(00000088)
              workspaceActiveBackground = rgba(00ff00ff)
              workspaceInactiveBackground = rgba(0000ffff)
              # workspaceActiveBorder = 
              # workspaceInactiveBorder = 
              dragAlpha = 0.5
              panelHeight = 200
              workspaceMargin = 30  
              workspaceBorderSize = 3 
              centerAligned = true
              overrideGaps = false
              gapsIn = 0
              gapsOut = 0
              hideBackgroundLayers = false
              drawActiveWorkspace = true
              autoDrag = true
              autoScroll = true
              exitOnClick = false
              switchOnDrop = false
              exitOnSwitch = trueß
              showNewWorkspace = true
              showEmptyWorkspace = false
          }
      }

      # allows repeated switching with same keypress that starts the submap
      binde = SUPER, TAB, exec, hyprswitch --daemon --do-initial-execute
      bind = SUPER, TAB, submap, switch
      bind = SUPER, TAB, exec, waybar_mode set "sw" 

      # allows repeated switching with same keypress that starts the submap
      binde = SUPER SHIFT, TAB, exec, hyprswitch --daemon --do-initial-execute -r
      bind = SUPER SHIFT, TAB, submap, switch
      bind = SUPER, TAB, exec, waybar_mode set "swr" 

      submap = switch
      # allow repeated window switching in submap (same keys as repeating while starting)
      binde = SUPER, TAB, exec, hyprswitch --daemon
      binde = SUPER SHIFT, TAB, exec, hyprswitch --daemon -r

      # switch to specific window offset
      bind = , 1, exec, hyprswitch --daemon --offset=1
      bind = , 2, exec, hyprswitch --daemon --offset=2
      bind = , 3, exec, hyprswitch --daemon --offset=3
      bind = , 4, exec, hyprswitch --daemon --offset=4
      bind = , 5, exec, hyprswitch --daemon --offset=5
      bind = , 6, exec, hyprswitch --daemon --offset=6
      bind = , 7, exec, hyprswitch --daemon --offset=7
      bind = , 8, exec, hyprswitch --daemon --offset=8
      bind = , 8, exec, hyprswitch --daemon --offset=8
      bind = , 9, exec, hyprswitch --daemon --offset=9

      bind = SUPER $reverse, 1, exec, hyprswitch --daemon --offset=1 -r
      bind = SUPER $reverse, 2, exec, hyprswitch --daemon --offset=2 -r
      bind = SUPER $reverse, 3, exec, hyprswitch --daemon --offset=3 -r
      bind = SUPER $reverse, 4, exec, hyprswitch --daemon --offset=4 -r
      bind = SUPER $reverse, 5, exec, hyprswitch --daemon --offset=5 -r
      bind = SUPER $reverse, 6, exec, hyprswitch --daemon --offset=6 -r
      bind = SUPER $reverse, 7, exec, hyprswitch --daemon --offset=7 -r
      bind = SUPER $reverse, 8, exec, hyprswitch --daemon --offset=8 -r
      bind = SUPER $reverse, 9, exec, hyprswitch --daemon --offset=9 -r
      bind = SUPER $reverse, 5, exec, hyprswitch --daemon --offset=5 -r


      # exit submap and stop hyprswitch
      bindrt = SUPER, SUPER_L, exec, hyprswitch --stop-daemon
      bindrt = SUPER, SUPER_L, submap, reset
      bindrt = SUPER, SUPER_L, exec, waybar_mode unset

      # if it somehow doesn't close on releasing $switch_release, escape can kill
      bindr = ,escape, exec, pkill hyprswitch
      bindr = ,escape, submap, reset
      submap = reset
      
    '';
  };

  home.file =
    let
      m = if host == "NxXPS" then monitors.xps.main.name else monitors.north.main.name;
    in
    {
      ".config/hypr/hyprlock.conf".text = ''
      background {
          monitor = ${m}

          # all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
          path = /home/nx2/Pictures/nix-wall.png
          blur_size = 4
          blur_passes = 3 # 0 disables blurring
          noise = 0.0117
          contrast = 1.3000 # Vibrant!!!
          brightness = 0.8000
          vibrancy = 0.2100
          vibrancy_darkness = 0.0
      }

      input-field {
          monitor =
          size = 250, 50
          outline_thickness = 1
          dots_size = 0.2 # Scale of input-field height, 0.2 - 0.8
          dots_spacing = 0.64 # Scale of dots' absolute size, 0.0 - 1.0
          dots_center = true
          outer_color = rgba(aaaaaaff)
          inner_color = rgba(000000ff)
          font_color = rgba(ffffffff)
          fade_on_empty = true
          placeholder_text = <i>Password...</i> # Text rendered in the input box when it's empty.
          hide_input = false
          position = 0, 50
          halign = center
          valign = bottom
      }

      # Current time
      label {
          monitor =
          text = cmd[update:1000] echo "<b><big> $(date +"%H:%M:%S") </big></b>"
          color = $color0
          font_size = 64
          font_family = ${rice.font.code.name} 10
          position = 0, 16
          halign = center
          valign = center
      }

      # User label
      label {
          monitor =
          text = Hey <span text_transform="capitalize" size="larger">$USER</span>
          color = $color0
          font_size = 20
          font_family = ${rice.font.code.name} 10
          position = 0, 0
          halign = center
          valign = center
      }


      # Type to unlock
      label {
          monitor =
          text = Type to unlock!
          color = $color0
          font_size = 16
          font_family = ${rice.font.code.name} 10
          position = 0, 30
          halign = center
          valign = bottom
      }
    '';
    };
}


# plugin {
#     hycov {
#         overview_gappo = 60             # gaps width from screen edge
#         overview_gappi = 24             # gaps width from clients
#         enable_hotarea = 0              # enable mouse cursor hotarea     
#         # hotarea_monitor = all           # monitor name which hotarea is in, default is all
#         # hotarea_pos = 1                 # position of hotarea (1: bottom left, 2: bottom right, 3: top left, 4: top right)
#         # hotarea_size = 10               # hotarea size, 10x10
#         # swipe_fingers = 4               # finger number of gesture,move any directory
#         move_focus_distance = 100       # distance for movefocus,only can use 3 finger to move 
#         enable_gesture = 0              # enable gesture
#         disable_workspace_change = 0    # disable workspace change when in overview mode
#         disable_spawn = 0               # disable bind exec when in overview mode
#         auto_exit = 1                   # enable auto exit when no client in overview
#         auto_fullscreen = 0             # auto make active window maximize after exit overview
#         only_active_workspace = 0       # only overview the active workspace
#         only_active_monitor = 1         # only overview the active monitor
#         enable_alt_release_exit = 0     # alt swith mode arg,see readme for detail
#         alt_replace_key = Alt_L         # alt swith mode arg,see readme for detail
#         alt_toggle_auto_next = 0        # auto focus next window when toggle overview in alt swith mode
#         click_in_cursor = 0             # when click to jump,the target windwo is find by cursor, not the current foucus window.
#         hight_of_titlebar = 0           # height deviation of title bar hight
#     }
# }
