# vim:fileencoding=utf-8:foldmethod=marker
{ pkgs, lib, nix-colors, config, ... }:

let
  base16-scheme = config.scheme.withHashtag;
in

{
  home.packages = with pkgs; [
    kitty kitty-img kitty-themes
  ];
  programs.kitty = {
    enable = true;
    package = pkgs.kitty;
    # stylix.targets.kitty.enable = true;
    font = {
      name = "JetBrainsMono Nerd Font";
      package = pkgs.nerdfonts;
    };
    settings = {
      themeFile = "Nord";
      enable_audio_bell = true;
      # foreground = "#${config.colorScheme.palette.base05}";
      # background = "#${config.colorScheme.palette.base00}";
      background_opacity = lib.mkForce "0.65";
      background_blur = "5";
      background_image = "../../Pictures/marvin.png";
      background_image_layout = "cscaled";
      background_tint = "0.95";
      dynamic_background_opacity = true;
      modify_font = "cell_width 90%";
      scrollback_lines = 10000;
      copy_on_select = "clipboard";  # Ensures text is copied when selected
      clipboard_control = "write-clipboard write-primary read-clipboard-ask read-primary-ask";
      allow_remote_control = "yes";
      update_check_interval = 0;
      shell = ".";
      allow_hyperlinks = "yes";
    };
    shellIntegration = {
      enableBashIntegration = true;
      enableZshIntegration = true;
    };
    keybindings = {
      "ctrl+c" = "copy_or_interrupt";
    };
    extraConfig = ''
      wayland_titlebar_color ${base16-scheme.base13};
      background ${base16-scheme.base00}
      foreground ${base16-scheme.base07}
      cursor ${base16-scheme.base07}
      selection_background ${base16-scheme.base10}
      selection_foreground ${base16-scheme.base07}

      color0 ${base16-scheme.base00}
      color1 ${base16-scheme.base08}
      color2 ${base16-scheme.base0B}
      color3 ${base16-scheme.base0A}
      color4 ${base16-scheme.base0D}
      color5 ${base16-scheme.base0E}
      color6 ${base16-scheme.base0C}
      color7 ${base16-scheme.base05}
      color8 ${base16-scheme.base03}
      color9 ${base16-scheme.base08}
      color10 ${base16-scheme.base0B}
      color11 ${base16-scheme.base0A}
      color12 ${base16-scheme.base0D}
      color13 ${base16-scheme.base0E}
      color14 ${base16-scheme.base0C}
      color15 ${base16-scheme.base07}
    '';
  };
}

# 0  #2E3440
# 1  #3B4252
# 2  #434C5E
# 3  #4C566A
# 4  #D8DEE9
# 5  #E5E9F0
# 6  #ECEFF4
# 7  #8FBCBB
# 8  #BF616A
# 9  #D08770
# 0  #EBCB8B
# 1  #A3BE8C
# 2  #88C0D0
# 3  #81A1C1
# 4  #B48EAD
# 5  #5E81AC