{
  lib,
  pkgs,
  config,
  ...
}:
{
  options = {
    custom.hyprland.enable = lib.mkEnableOption "Enable hyprland config";
  };
  config = lib.mkIf config.custom.hyprland.enable {
    xdg.dataFile = {
      avatar = {
        source = ./avatar.png;
        target = "images/avatar.png";
      };
    };
    programs = {
      vicinae.enable = true;
      ghostty = {
        enable = true;
        settings = {
          font-family = "FiraCode Nerd Font";
          window-padding-x = 15;
          window-padding-y = 10;
          confirm-close-surface = false;
          resize-overlay = "never";
          app-notifications = "no-clipboard-copy";
        };
      };
      hyprlock = {
        enable = true;
        settings = {
          "$font" = "Roboto";

          general = {
            hide_cursor = true;
          };

          background = {
            monitor = "";
          };

          label = {
            monitor = "";
            text = "$LAYOUT[EN,RU]";
            font_size = 18;
            font_family = "$font";
            position = "0, -120";
            halign = "center";
            valign = "center";
          };

          image = {
            monitor = "";
            path = "$HOME/.local/share/images/avatar.png";
            size = 120;
            rounding = 10;
            border_size = 2;
            position = "0, 100";
            halign = "center";
            valign = "center";
          };

          input-field = {
            monitor = "";
            size = "300, 60";
            outline_thickness = 2;
            dots_size = 0.2;
            dots_spacing = 0.2;
            dots_center = true;
            placeholder_text = "Введите пароль";
            fade_on_empty = false;
            hide_input = false;
            fail_text = "Неверный пароль";
            position = "0, -47";
            halign = "center";
            valign = "center";
          };
        };
      };
    };
    home.packages = with pkgs; [
      acpi
      grim
      jq
      slurp
      wl-clipboard
    ];
    wayland.windowManager.hyprland = {
      enable = true;
      settings = {
        general = {
          layout = "master";
          border_size = 3;
          gaps_in = 7;
          gaps_out = 14;
        };
        decoration.rounding = 10;
        input = {
          kb_layout = "us,ru";
          kb_options = "grp:alt_shift_toggle";
          touchpad.natural_scroll = true;
        };
        "$mainMod" = "SUPER";
        bindm = [
          "$mainMod, mouse:272, movewindow"
          "$mainMod, mouse:273, resizewindow"
        ];
        bind = [
          "$mainMod SHIFT, Q, exit,"

          "$mainMod, RETURN, exec, ghostty"
          "$mainMod, D, exec, vicinae open"

          "$mainMod, Q, killactive,"
          "$mainMod, V, togglefloating,"
          "$mainMod, F, fullscreen"

          "$mainMod, K, layoutmsg, cycleprev"
          "$mainMod, J, layoutmsg, cyclenext"

          "$mainMod SHIFT, K, layoutmsg, swapprev"
          "$mainMod SHIFT, J, layoutmsg, swapnext"

          "$mainMod, L, exec, loginctl lock-session"

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

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

          ", Print, exec, mkdir -p ~/Изображения/Скриншоты && grim -o \"$(hyprctl activeworkspace -j | jq -r '.monitor')\" - | tee ~/Изображения/Скриншоты/`date +'%Y_%m_%d_%H_%M_%S_%3N.png'` | wl-copy && dunstify \"Снимок всего экрана сделан\""
          "SHIFT, Print, exec, mkdir -p ~/Изображения/Скриншоты && grim -g \"$(slurp -d)\" - | tee ~/Изображения/Скриншоты/`date +'%Y_%m_%d_%H_%M_%S_%3N.png'` | wl-copy && dunstify 'Снимок области сделан'"

          ", 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"

          ", XF86MonBrightnessUp, exec, brightnessctl set +10%"
          ", XF86MonBrightnessDown, exec, brightnessctl set 10%-"
        ];
        gesture = [
          "3, horizontal, workspace"
        ];
        exec-once = [
          "dunst"
          "waybar"
          "vicinae server"
        ];
      };
    };
    services = {
      hyprpaper = {
        enable = true;
        settings = {
          splash = false;
        };
      };
      network-manager-applet.enable = true;
      blueman-applet.enable = true;
      dunst = {
        enable = true;
        settings = {
          global = {
            font = "Roboto 12";
            corner_radius = 16;
          };
        };
      };
      hypridle = {
        enable = true;
        settings = {
          general = {
            lock_cmd = "pidof hyprlock || hyprlock";
            before_sleep_cmd = "loginctl lock-session";
            after_sleep_cmd = "hyprctl dispatch dpms on";
          };

          listener = [
            {
              timeout = 150;
              on-timeout = "brightnessctl -s set 10";
              on-resume = "brightnessctl -r";
            }
            {
              timeout = 300;
              on-timeout = "loginctl lock-session";
            }
            {
              timeout = 330;
              on-timeout = "hyprctl dispatch dpms off";
              on-resume = "hyprctl dispatch dpms on && brightnessctl -r";
            }
            {
              timeout = 1800;
              on-timeout = "systemctl suspend";
            }
          ];
        };
      };
    };
  };
}
