aboutsummaryrefslogtreecommitdiff
path: root/modules/home/desktop/components/fcitx5/default.nix
blob: f4c06b0fc85f5bb40ffe6f5bd7748ff2781775ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{ options, config, lib, pkgs, namespace, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.desktop.components.fcitx5;
  desktop = config.${namespace}.desktop;
in {
  options.${namespace}.desktop.components.fcitx5 = with types; {
    enable = mkEnableOption "fcitx5";
  };

  config = mkIf cfg.enable {
    i18n.inputMethod = {
      enable = true;
      type = "fcitx5";

      fcitx5 = {
        addons = with pkgs; [ fcitx5-mozc ];

        settings = {
          globalOptions = {
            "Hotkey/TriggerKeys" = {
              "0" = "Scroll_Lock";
            };

            Behavior = {
              ActiveByDefault = "True"; # `true` outputs lowercase "true"
              # resetStateWhenFocusIn = "All";
              ShareInputState = "All";
            };
          };

          inputMethod = {
            GroupOrder."0" = "Default";

            "Groups/0" = {
              Name = "Default";
              "Default Layout" = "us";
              DefaultIM = "keyboard-us";
            };

            "Groups/0/Items/0".Name = "mozc";
            "Groups/0/Items/1".Name = "keyboard-us";
          };

          addons = {
            classicui.globalSection.Theme = "nix-theme";
          };
        };

        themes = {
          "nix-theme".theme = let
            c = desktop.theme.colors;
          in {
            "Metadata" = {
              Name = "nix-theme";
              Author = "CartConnoisseur";
              Description = "Theme generated by NixOS";
              Version = 1;
            };

            "InputPanel" = {
              NormalColor = "#${c.fg}";
              HighlightColor = "#${c.fg}";
              HighlightBackgroundColor = "#00000000";
              HighlightCandidateColor = "#${c.bg}";

              FullWidthHighlight = true;
              PageButtonAlignment = "Last Candidate";
            };

            "InputPanel/Background" = {
              Color = "#${c.bg}";
              BorderColor = "#${c.fg1}";
              BorderWidth = 2;
            };

            # "InputPanel/Background/Margin" = {
            #   Left = 10;
            #   Right = 10;
            #   Top = 10;
            #   Bottom = 10;
            # };

            "InputPanel/Highlight" = {
              Color = "#${c.fg}";
              BorderWidth = 0;
            };

            "InputPanel/Highlight/Margin" = {
              Left = 2;
              Right = 2;
              Top = 2;
              Bottom = 2;
            };

            "InputPanel/ContentMargin" = {
              Left = 2;
              Right = 2;
              Top = 2;
              Bottom = 2;
            };

            "InputPanel/TextMargin" = {
              Left = 5;
              Right = 5;
              Top = 5;
              Bottom = 5;
            };
          };
        };
      };
    };

    home.sessionVariables = {
      # required for fcitx5 support in kitty
      GLFW_IM_MODULE = "ibus";
    };
  };
}