{
  lib,
  config,
  ...
}: let
  inherit (lib) mkEnableOption mkIf;
  cfg = config.horseman.hardware.keyd;
in {
  options = {
    horseman.hardware.keyd = {
      enable = mkEnableOption "Kanata, the key remapper";
    };
  };

  config = mkIf cfg.enable {
    services.keyd = {
      enable = true;

      keyboards.main = {
        ids = ["*"];
        settings = {
          main = {
            capslock = "overload(control, esc)";
            esc = "capslock";
          };
        };
      };
    };
  };
}
