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

with lib;
let
  cfg = config.samfelag.modules.system.input.greek;
  hyprCfg = config.samfelag.modules.desktop.wm.hyprland;
in
{
  options.samfelag.modules.system.input.greek = {
    enable = mkEnableOption "Enable greek input";
  };

  config = mkIf cfg.enable {

    i18n.inputMethod = {
      type = "fcitx5";
      enable = true;
      fcitx5.addons = with pkgs; [
        fcitx5-gtk
        fcitx5-nord
      ];
    };

    environment.variables = {
      # GTK_IM_MODULE = "fcitx";
      QT_IM_MODULE = "fcitx";
      XMODIFIERS = "@im=fcitx";
    };

    hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable {
      windowrule = "pseudo, class:fcitx";
      exec-once = [
        "fcitx -d -r"
        "fcitx-remote -r"
      ];
    };

  };
}
