From 66938043d57e3811f2277635a7a618a9a02ba97b Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Mon, 15 Sep 2025 15:22:41 -0700 Subject: fcitx5: move config to home manager --- modules/home/desktop/components/fcitx5/default.nix | 159 +++++++++++++-------- 1 file changed, 98 insertions(+), 61 deletions(-) (limited to 'modules/home/desktop/components/fcitx5') diff --git a/modules/home/desktop/components/fcitx5/default.nix b/modules/home/desktop/components/fcitx5/default.nix index 0eb0a4c..f4c06b0 100644 --- a/modules/home/desktop/components/fcitx5/default.nix +++ b/modules/home/desktop/components/fcitx5/default.nix @@ -1,82 +1,119 @@ -{ options, config, osConfig, lib, pkgs, namespace, ... }: +{ options, config, lib, pkgs, namespace, ... }: with lib; with lib.${namespace}; let cfg = config.${namespace}.desktop.components.fcitx5; - oscfg = osConfig.${namespace}.hardware.keyboard.jp; desktop = config.${namespace}.desktop; - impermanence = config.${namespace}.impermanence; in { options.${namespace}.desktop.components.fcitx5 = with types; { - enable = mkEnableOption "fcitx5 theming"; + enable = mkEnableOption "fcitx5"; }; - config = mkIf (cfg.enable && oscfg.enable) { - #TODO: investigate generating config files instead of persisting - home.persistence.${impermanence.location} = { - directories = [ - ".config/fcitx" - ".config/fcitx5" - ]; - }; + config = mkIf cfg.enable { + i18n.inputMethod = { + enable = true; + type = "fcitx5"; - xdg.dataFile."fcitx5/themes/nix-theme/theme.conf".source = let - c = desktop.theme.colors; - in (pkgs.formats.ini {}).generate "fcitx5-theme.conf" { - "Metadata" = { - Name = "nix-theme"; - Author = "CartConnoisseur"; - Description = "Theme generated by NixOS"; - Version = 1; - }; + fcitx5 = { + addons = with pkgs; [ fcitx5-mozc ]; - "InputPanel" = { - NormalColor = "#${c.fg}"; - HighlightColor = "#${c.fg}"; - HighlightBackgroundColor = "#00000000"; - HighlightCandidateColor = "#${c.bg}"; + settings = { + globalOptions = { + "Hotkey/TriggerKeys" = { + "0" = "Scroll_Lock"; + }; - FullWidthHighlight = true; - PageButtonAlignment = "Last Candidate"; - }; + Behavior = { + ActiveByDefault = "True"; # `true` outputs lowercase "true" + # resetStateWhenFocusIn = "All"; + ShareInputState = "All"; + }; + }; - "InputPanel/Background" = { - Color = "#${c.bg}"; - BorderColor = "#${c.fg1}"; - BorderWidth = 2; - }; + inputMethod = { + GroupOrder."0" = "Default"; - # "InputPanel/Background/Margin" = { - # Left = 10; - # Right = 10; - # Top = 10; - # Bottom = 10; - # }; + "Groups/0" = { + Name = "Default"; + "Default Layout" = "us"; + DefaultIM = "keyboard-us"; + }; - "InputPanel/Highlight" = { - Color = "#${c.fg}"; - BorderWidth = 0; - }; + "Groups/0/Items/0".Name = "mozc"; + "Groups/0/Items/1".Name = "keyboard-us"; + }; - "InputPanel/Highlight/Margin" = { - Left = 2; - Right = 2; - Top = 2; - Bottom = 2; - }; + addons = { + classicui.globalSection.Theme = "nix-theme"; + }; + }; - "InputPanel/ContentMargin" = { - Left = 2; - Right = 2; - Top = 2; - Bottom = 2; - }; + 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}"; - "InputPanel/TextMargin" = { - Left = 5; - Right = 5; - Top = 5; - Bottom = 5; + 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"; + }; }; } -- cgit v1.2.3