{ config, lib, ... }:

{
  config = lib.mkIf config.desktop.enable {

    home-manager.users.${config.user} = {
      programs.kitty = {

        enable = true;
        environment = { };
        extraConfig = "";

        settings = {
          # Font
          font_family = config.theme.monospaceFont;
          font_size = 11;
          bold_font = "auto";
          italic_font = "auto";
          bold_italic_font = "auto";

          # Scrollback
          scrollback_lines = 10000;
          scrollback_pager_history_size = 300; # MB

          # Urls
          detect_urls = true;
          show_hyperlink_targets = false;

          # Window
          window_padding_width = config.theme.outerGap;
          window_border_width = 0;
          draw_minimal_borders = true;
          background_opacity = config.theme.opacity;

          # Disable audio
          enable_audio_bell = false;

          # Disable close prompt
          confirm_os_window_close = 0;

          # colors
          background = "#${config.theme.colors.base00}";
          foreground = "#${config.theme.colors.base05}";
          selection_background = "#${config.theme.colors.base05}";
          selection_foreground = "#${config.theme.colors.base00}";
          url_color = "#${config.theme.colors.base04}";
          cursor = "#${config.theme.colors.base05}";
          active_border_color = "#${config.theme.colors.base03}";
          inactive_border_color = "#${config.theme.colors.base01}";
          active_tab_background = "#${config.theme.colors.base00}";
          active_tab_foreground = "#${config.theme.colors.base05}";
          inactive_tab_background = "#${config.theme.colors.base01}";
          inactive_tab_foreground = "#${config.theme.colors.base04}";
          tab_bar_background = "#${config.theme.colors.base01}";

          # normal
          color0 = "#${config.theme.colors.base00}";
          color1 = "#${config.theme.colors.base08}";
          color2 = "#${config.theme.colors.base0B}";
          color3 = "#${config.theme.colors.base0A}";
          color4 = "#${config.theme.colors.base0D}";
          color5 = "#${config.theme.colors.base0E}";
          color6 = "#${config.theme.colors.base0C}";
          color7 = "#${config.theme.colors.base05}";

          # bright
          color8 = "#${config.theme.colors.base03}";
          color9 = "#${config.theme.colors.base08}";
          color10 = "#${config.theme.colors.base0B}";
          color11 = "#${config.theme.colors.base0A}";
          color12 = "#${config.theme.colors.base0D}";
          color13 = "#${config.theme.colors.base0E}";
          color14 = "#${config.theme.colors.base0C}";
          color15 = "#${config.theme.colors.base07}";

          # extended base16 colors
          color16 = "#${config.theme.colors.base09}";
          color17 = "#${config.theme.colors.base0F}";
          color18 = "#${config.theme.colors.base01}";
          color19 = "#${config.theme.colors.base02}";
          color20 = "#${config.theme.colors.base04}";
          color21 = "#${config.theme.colors.base06}";
        };
      };
    };

  };
}