mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
fcitx5: add themes and classicUiConfig options (#6876)
This commit is contained in:
parent
c9433ae62f
commit
6899001a76
2 changed files with 92 additions and 1 deletions
|
|
@ -37,6 +37,48 @@ in
|
||||||
See [Using Fcitx 5 on Wayland](https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland).
|
See [Using Fcitx 5 on Wayland](https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
classicUiConfig = lib.mkOption {
|
||||||
|
type = with lib.types; either path lines;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Configuration to be written to {file}`$XDG_DATA_HOME/fcitx5/conf/classicui.conf`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
themes = lib.mkOption {
|
||||||
|
type =
|
||||||
|
with lib.types;
|
||||||
|
lazyAttrsOf (submodule {
|
||||||
|
options = {
|
||||||
|
theme = lib.mkOption {
|
||||||
|
type = with lib.types; nullOr (either lines path);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
The `theme.conf` file of the theme.
|
||||||
|
|
||||||
|
See https://fcitx-im.org/wiki/Fcitx_5_Theme#Background_images
|
||||||
|
for more information.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
highlightImage = lib.mkOption {
|
||||||
|
type = with lib.types; nullOr path;
|
||||||
|
default = null;
|
||||||
|
description = "Path to the SVG of the highlight.";
|
||||||
|
};
|
||||||
|
panelImage = lib.mkOption {
|
||||||
|
type = with lib.types; nullOr path;
|
||||||
|
default = null;
|
||||||
|
description = "Path to the SVG of the panel.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
example = "";
|
||||||
|
description = ''
|
||||||
|
Themes to be written to {file}`$XDG_DATA_HOME/fcitx5/themes/''${name}`
|
||||||
|
'';
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -58,6 +100,40 @@ in
|
||||||
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xdg =
|
||||||
|
let
|
||||||
|
mkThemeConfig = name: attrs: {
|
||||||
|
dataFile = {
|
||||||
|
"fcitx5/themes/${name}/highlight.svg" = lib.mkIf (attrs.highlightImage != null) {
|
||||||
|
source = attrs.highlightImage;
|
||||||
|
};
|
||||||
|
"fcitx5/themes/${name}/panel.svg" = lib.mkIf (attrs.panelImage != null) {
|
||||||
|
source = attrs.panelImage;
|
||||||
|
};
|
||||||
|
"fcitx5/themes/${name}/theme.conf" = lib.mkIf (attrs.theme != null) {
|
||||||
|
source =
|
||||||
|
if builtins.isPath attrs.theme || lib.isStorePath attrs.theme then
|
||||||
|
attrs.theme
|
||||||
|
else
|
||||||
|
pkgs.writeText "fcitx5-theme.conf" attrs.theme;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.mkMerge (
|
||||||
|
[
|
||||||
|
(lib.mkIf (cfg.classicUiConfig != "") {
|
||||||
|
dataFile."fcitx5/conf/classicui.conf".source = (
|
||||||
|
if builtins.isPath cfg.classicUiConfig || lib.isStorePath cfg.classicUiConfig then
|
||||||
|
cfg.classicUiConfig
|
||||||
|
else
|
||||||
|
pkgs.writeText "fcitx5-classicui.conf" cfg.classicUiConfig
|
||||||
|
);
|
||||||
|
})
|
||||||
|
]
|
||||||
|
++ (builtins.attrValues (lib.mapAttrs mkThemeConfig cfg.themes))
|
||||||
|
);
|
||||||
|
|
||||||
systemd.user.services.fcitx5-daemon = {
|
systemd.user.services.fcitx5-daemon = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Fcitx5 input method editor";
|
Description = "Fcitx5 input method editor";
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,28 @@
|
||||||
lib.mkIf config.test.enableBig {
|
lib.mkIf config.test.enableBig {
|
||||||
i18n.inputMethod = {
|
i18n.inputMethod = {
|
||||||
enabled = "fcitx5";
|
enabled = "fcitx5";
|
||||||
fcitx5.waylandFrontend = true;
|
fcitx5 = {
|
||||||
|
waylandFrontend = true;
|
||||||
|
themes.example = {
|
||||||
|
theme = ''
|
||||||
|
[Metadata]
|
||||||
|
Name=example
|
||||||
|
Version=0.1
|
||||||
|
Author=home-manager
|
||||||
|
Description=Theme for testing
|
||||||
|
ScaleWithDPI=True
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
classicUiConfig = "Theme=example";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
_module.args.pkgs = lib.mkForce realPkgs;
|
_module.args.pkgs = lib.mkForce realPkgs;
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service
|
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service
|
||||||
|
assertFileExists home-files/.local/share/fcitx5/themes/example/theme.conf
|
||||||
|
assertFileExists home-files/.local/share/fcitx5/conf/classicui.conf
|
||||||
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'GTK_IM_MODULE'
|
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'GTK_IM_MODULE'
|
||||||
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'QT_IM_MODULE'
|
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'QT_IM_MODULE'
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue