diff --git a/hosts/common/programs/default.nix b/hosts/common/programs/default.nix index 1fd35094..b9aae5a4 100644 --- a/hosts/common/programs/default.nix +++ b/hosts/common/programs/default.nix @@ -28,6 +28,7 @@ ./element-desktop.nix ./epiphany.nix ./evince.nix + ./fcitx5.nix ./feedbackd.nix ./firefox.nix ./firejail.nix diff --git a/hosts/common/programs/fcitx5.nix b/hosts/common/programs/fcitx5.nix new file mode 100644 index 00000000..2b40b7f5 --- /dev/null +++ b/hosts/common/programs/fcitx5.nix @@ -0,0 +1,123 @@ +# fcitx5 is an "input method", to e.g. allow typing CJK on qwerty. +# but i also misuse it to allow typing emoji on qwerty: +# - press `Super+backtick` +# - type something like "effort" +# - it should be underlined, at the least +# - if well supported (e.g. Firefox; also gtk4, alacritty on sway 1.10+), a drop-down fuzzy matcher will appear +# - press space +# - "effort" should be replaced by `(ง •̀_•́)ง` +# +## debugging +# - `fcitx5-diagnose` +# +## config/docs: +# - `fcitx5-configtool`, then check ~/.config/fcitx5 files +# - +# - +# - theming: +# - +# - wayland specifics: +# - quickphrase (emoji): +# - override phrases via `~/.config/fcitx/data/QuickPhrase.mb` +# - customize bindings via `fcitx5-configtool` > addons > QuickPhrase +# - theming: +# - nixpkgs has a few themes: `fcitx5-{material-color,nord,rose-pine}` +# - NUR has a few themes +# - +{ config, lib, pkgs, ... }: +let + cfg = config.sane.programs.fcitx5; +in +{ + sane.programs.fcitx5 = { + packageUnwrapped = pkgs.fcitx5-with-addons.override { + addons = with pkgs; [ + # fcitx5-mozc # japanese input: + fcitx5-gtk # + ]; + }; + + sandbox.method = "bwrap"; + sandbox.whitelistDbus = [ "user" ]; + sandbox.whitelistWayland = true; # for `fcitx5-configtool, if nothing else` + sandbox.extraHomePaths = [ + # ".config/fcitx" + ".config/fcitx5" + ".local/share/fcitx5" + ]; + + fs.".config/fcitx5/conf/quickphrase.conf".symlink.text = '' + # Choose key modifier + Choose Modifier=None + # Enable Spell check + Spell=True + FallbackSpellLanguage=en + + [TriggerKey] + # defaults: Super+grave, Super+semicolon + # gtk apps use ctrl+period, so super+period is a nice complement + 0=Super+grave + 1=Super+semicolon + 2=Super+period + ''; + fs.".config/fcitx5/conf/classicui.conf".symlink.text = '' + Theme=sane + Font="Sans 20" + Vertical Candidate List=True + ''; + fs.".local/share/fcitx5/themes/sane/theme.conf".symlink.text = '' + # i omit several keys, especially the ones which don't seem to do much. + # for a theme which uses many more options, see: + # - + [Metadata] + Name=sane + ScaleWithDPI=True + + [InputPanel] + NormalColor=#d8d8d8 + HighlightCandidateColor=#FFFFFF + HighlightColor=#FFFFFF + HighlightBackgroundColor=#1f5e54 + + [InputPanel/Background] + Color=#1f5e54 + + [InputPanel/Highlight] + Color=#418379 + + [InputPanel/Highlight/Margin] + Left=20 + Right=20 + Top=7 + Bottom=7 + + [InputPanel/TextMargin] + Left=20 + Right=20 + Top=6 + Bottom=6 + ''; + + services.fcitx5 = { + description = "fcitx5: input method (IME) for emoji/internationalization"; + after = [ "graphical-session.target" ]; + wantedBy = [ "graphical-session.target" ]; + + serviceConfig = { + ExecStart="${cfg.package}/bin/fcitx5"; + Type = "simple"; + Restart = "always"; + RestartSec = "10s"; + }; + }; + + env.XMODIFIERS = "@im=fcitx"; + # setting IM_MODULE is generally not required on wayland, but can be used to override the toolkit's own dialogs with our own. + # env.GTK_IM_MODULE = "fcitx"; + # enable if you want them: + # env.QT_IM_MODULE = "fcitx"; + # env.QT_PLUGIN_PATH = [ "${cfg.package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ]; + # env.SDL_IM_MODULE = "fcitx"; + # env.GLFW_IM_MODULE = "ibus"; # for KiTTY, as per + }; +} diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index a3d7cc41..800f71c3 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -128,6 +128,7 @@ in "blueberry" # GUI bluetooth manager "brightnessctl" "conky" # for a nice background + "fcitx5" # input method; emoji "fontconfig" # "gnome.gnome-bluetooth" # XXX(2023/05/14): broken # "gnome.gnome-control-center" # XXX(2023/06/28): depends on webkitgtk4_1