feat: add chinese hanyu input methods

This commit is contained in:
Youwen Wu 2025-08-03 16:12:08 +08:00
parent 8c56482975
commit fcee8ea9e3
Signed by: youwen
GPG key ID: 865658ED1FE61EC3
5 changed files with 256 additions and 90 deletions

View file

@ -65,6 +65,13 @@ in
Whether to enable `hyprsunset` as a daemon.
'';
};
fcitx5.enable = lib.mkOption {
type = lib.types.bool;
default = osConfig.i18n.inputMethod.enable && (osConfig.i18n.inputMethod.type == "fcitx5");
description = ''
Whether to execute fcitx5 at startup.
'';
};
};
config = lib.mkIf cfg.enable {
@ -86,9 +93,14 @@ in
enable = true;
plugins = [ pkgs.hyprlandPlugins.hyprscroller ];
settings = {
exec-once = [
exec-once =
[
"hyprctl dispatch workspace 100000"
];
]
++ (lib.optionals cfg.fcitx5.enable [
"fcitx5 -d -r"
"fcitx5-remote -r"
]);
"$mod" = "SUPER";
"$Left" = "H";
"$Right" = "L";

View file

@ -1,7 +1,11 @@
{ config, lib, ... }:
let
cfg = config.liminalOS.desktop.hyprland;
in
{
config.wayland.windowManager.hyprland.settings.windowrulev2 =
lib.mkIf config.liminalOS.desktop.hyprland.enable
(
[
"opacity 0.90 0.90,class:^(librewolf)$"
"opacity 0.90 0.90,class:^(floorp)$"
@ -93,5 +97,9 @@
"size 50% 50%,class:^(org.pulseaudio.pavucontrol)"
"stayfocused, class:^(pinentry-)" # fix pinentry losing focus
];
]
++ (lib.optionals cfg.fcitx5.enable [
"pseudo, class:^(fcitx)"
])
);
}

View file

@ -15,6 +15,7 @@
./wine
./wsl
./graphics
./localization
];
options.liminalOS.enable = lib.mkOption {

View file

@ -0,0 +1,143 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.liminalOS.desktop.localization;
in
{
options.liminalOS.desktop.localization = {
chinese.input.enable = lib.mkEnableOption "Chinese input method using fcitx5.";
chinese.script = lib.mkOption {
type = lib.types.enum [
"simplified"
"traditional"
];
default = "simplified";
description = ''
Whether to use simplified or traditional characters.
'';
};
};
config = lib.mkIf cfg.chinese.input.enable {
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.waylandFrontend = true;
fcitx5.addons = with pkgs; [
fcitx5-gtk
fcitx5-chinese-addons
fcitx5-tokyonight
];
fcitx5.settings.globalOptions = {
Hotkey = {
# Enumerate when press trigger key repeatedly
EnumerateWithTriggerKeys = true;
# Temporally switch between first and current Input Method
AltTriggerKeys = null;
# Enumerate Input Method Forward
EnumerateForwardKeys = null;
# Enumerate Input Method Backward
EnumerateBackwardKeys = null;
# Skip first input method while enumerating
EnumerateSkipFirst = false;
# Enumerate Input Method Group Forward
EnumerateGroupForwardKeys = null;
# Enumerate Input Method Group Backward
EnumerateGroupBackwardKeys = null;
# Activate Input Method
ActivateKeys = null;
# Deactivate Input Method
DeactivateKeys = null;
# Default Previous page
PrevPage = null;
# Default Next page
NextPage = null;
# Default Previous Candidate
PrevCandidate = null;
# Default Next Candidate
NextCandidate = null;
# Toggle embedded preedit
TogglePreedit = null;
# Time limit in milliseconds for triggering modifier key shortcuts
ModifierOnlyKeyTimeout = 250;
};
"Hotkey/TriggerKeys" = {
"0" = "Control+Super+space";
"1" = "Zenkaku_Hankaku";
"2" = "Hangul";
};
Behavior = {
# Active By Default;
ActiveByDefault = false;
# Reset state on Focus In;
resetStateWhenFocusIn = "No";
# Share Input State;
ShareInputState = "No";
# Show preedit in application;
PreeditEnabledByDefault = true;
# Show Input Method Information when switch input method;
ShowInputMethodInformation = true;
# Show Input Method Information when changing focus;
showInputMethodInformationWhenFocusIn = false;
# Show compact input method information;
CompactInputMethodInformation = true;
# Show first input method information;
ShowFirstInputMethodInformation = true;
# Default page size;
DefaultPageSize = 10;
# Override Xkb Option;
OverrideXkbOption = false;
# Custom Xkb Option;
CustomXkbOption = "";
# Force Enabled Addons;
EnabledAddons = "";
# Force Disabled Addons;
DisabledAddons = "";
# Preload input method to be used by default;
PreloadInputMethod = true;
# Allow input method in the password field;
AllowInputMethodForPassword = false;
# Show preedit text when typing password;
ShowPreeditForPassword = false;
# Interval of saving user data in minutes;
AutoSavePeriod = 30;
};
};
fcitx5.settings.inputMethod = {
"Groups/0" = {
# Group Name
Name = "Default";
# Layout
"Default Layout" = "us";
# Default Input Method
DefaultIM = "pinyin";
};
"Groups/0/Items/0" = {
# Name
Name = "keyboard-us";
# Layout
Layout = "";
};
"Groups/0/Items/1" = {
# Name
Name = "pinyin";
# Layout
Layout = "";
};
"GroupOrder" = {
"0" = "Default";
};
};
};
};
}

View file

@ -144,6 +144,8 @@
polarity = lib.mkDefault "dark";
};
liminalOS.desktop.localization.chinese.input.enable = true;
environment.etc.polarity.text = lib.mkDefault "dusk";
specialisation = {