{ config, lib, pkgs, ... }:

let
  inherit (lib) mkIf mkOption types;
  cfg = config.terminals;
in
{
  imports = [
    ./subs/ghostty.nix
    ./subs/alacritty.nix
    ./subs/foot.nix
  ];

  options.terminals = {
    ghostty.enable = mkOption {
      default = true;
      type = types.bool;
    };
    alacritty.enable = mkOption {
      default = true;
      type = types.bool;
    };
    xfceTerminal.enable = mkOption {
      default = false;
      type = types.bool;
    };
  };

  config = {
    subs.ghostty.enable = cfg.ghostty.enable;
    subs.alacritty.enable = cfg.alacritty.enable;

    home.packages = mkIf cfg.xfceTerminal.enable [ pkgs.xfce.xfce4-terminal ];

    home.file = {
      ".config/alacritty/themes/dracula.toml".source = mkIf cfg.alacritty.enable ../config/dracula.toml;
      ".config/ghostty/themes/ghostty-dracula".source = mkIf cfg.ghostty.enable ../config/ghostty-dracula;
    };
  };
}
