From 783318e968bbbbc86a6b207fcff26fc74586d15d Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 3 Nov 2025 22:43:55 +0100 Subject: [PATCH] fix input method --- hosts/nixos/thinkpad/system.nix | 10 ---- modules/hyprland/home.nix | 97 +++++++++++++++++++++++++++++++-- modules/hyprland/system.nix | 11 ++++ 3 files changed, 104 insertions(+), 14 deletions(-) diff --git a/hosts/nixos/thinkpad/system.nix b/hosts/nixos/thinkpad/system.nix index 65f126a..2d9fef7 100644 --- a/hosts/nixos/thinkpad/system.nix +++ b/hosts/nixos/thinkpad/system.nix @@ -90,16 +90,6 @@ pulse.enable = true; }; - # Input method configuration - i18n.inputMethod = { - enable = true; - type = "ibus"; - ibus.engines = with pkgs.ibus-engines; [ - libpinyin # Chinese Simplified Pinyin - mozc # Japanese (Romaji) - ]; - }; - # Touchpad configuration (host-specific overrides) services.libinput.touchpad = { disableWhileTyping = true; diff --git a/modules/hyprland/home.nix b/modules/hyprland/home.nix index f4c84cd..31d79cc 100644 --- a/modules/hyprland/home.nix +++ b/modules/hyprland/home.nix @@ -1,6 +1,79 @@ { config, pkgs, ... }: { + # Fcitx5 input method configuration + xdg.configFile."fcitx5/profile" = { + force = true; + text = '' + [Groups/0] + Name=Default + Default Layout=us + DefaultIMName=keyboard-us + + [Groups/0/Items/0] + Name=keyboard-us + Layout= + + [Groups/0/Items/1] + Name=rime + Layout= + + [Groups/0/Items/2] + Name=mozc + Layout= + + [GroupOrder] + 0=Default + ''; + }; + + xdg.configFile."fcitx5/config" = { + force = true; + text = '' + [Hotkey] + TriggerKeys= + EnumerateWithTriggerKeys=True + AltTriggerKeys= + EnumerateForwardKeys= + EnumerateBackwardKeys= + EnumerateSkipFirst=False + + [Behavior] + ActiveByDefault=False + ShareInputState=No + ''; + }; + + # Rime configuration for Simplified Chinese + xdg.configFile."fcitx5/rime/default.custom.yaml" = { + force = true; + text = '' + patch: + schema_list: + - schema: luna_pinyin_simp + menu: + page_size: 7 + ''; + }; + + # Rime addon configuration - 7 candidates per page + xdg.configFile."fcitx5/conf/rime.conf" = { + force = true; + text = '' + [InputMethod] + PageSize=7 + ''; + }; + + # Mozc addon configuration - 7 candidates per page + xdg.configFile."fcitx5/conf/mozc.conf" = { + force = true; + text = '' + [InputMethod] + PageSize=7 + ''; + }; + wayland.windowManager.hyprland = { enable = true; xwayland.enable = true; @@ -11,14 +84,14 @@ # Environment variables for input methods env = [ - "GTK_IM_MODULE,ibus" - "QT_IM_MODULE,ibus" - "XMODIFIERS,@im=ibus" + "GTK_IM_MODULE,fcitx" + "QT_IM_MODULE,fcitx" + "XMODIFIERS,@im=fcitx" ]; # Execute apps at launch exec-once = [ - "ibus-daemon -drx" + "fcitx5 -d" "hypridle" "waybar" "nm-applet --indicator" @@ -103,6 +176,22 @@ "SUPER, Return, exec, ghostty" "SUPER, Space, exec, wofi --show drun" + # Input method switching (cycles through configured IMs) + "ALT, Space, exec, ${pkgs.writeShellScript "fcitx5-cycle" '' + current=$(${pkgs.fcitx5}/bin/fcitx5-remote -n) + case "$current" in + keyboard-us) + ${pkgs.fcitx5}/bin/fcitx5-remote -s rime + ;; + rime) + ${pkgs.fcitx5}/bin/fcitx5-remote -s mozc + ;; + mozc|*) + ${pkgs.fcitx5}/bin/fcitx5-remote -s keyboard-us + ;; + esac + ''}" + # Window focus navigation (vim-style) "SUPER, h, movefocus, l" "SUPER, j, movefocus, d" diff --git a/modules/hyprland/system.nix b/modules/hyprland/system.nix index e9fa7d1..209ae09 100644 --- a/modules/hyprland/system.nix +++ b/modules/hyprland/system.nix @@ -38,6 +38,17 @@ }; }; + # Input method configuration for Hyprland + i18n.inputMethod = { + enable = true; + type = "fcitx5"; + fcitx5.addons = with pkgs; [ + fcitx5-rime # Chinese Simplified/Traditional (more powerful than libpinyin) + fcitx5-mozc # Japanese (Romaji) + fcitx5-gtk # GTK integration + ]; + }; + # System packages for Hyprland environment.systemPackages = with pkgs; [ hyprland