2022-05-04 00:29:17 +02:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.home.pointerCursor;
|
|
|
|
|
|
|
|
pointerCursorModule = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
example = literalExpression "pkgs.vanilla-dmz";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Package providing the cursor theme.";
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "Vanilla-DMZ";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The cursor name within the package.";
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 32;
|
|
|
|
example = 64;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The cursor size.";
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
x11 = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption ''
|
2023-07-01 01:30:13 +02:00
|
|
|
x11 config generation for {option}`home.pointerCursor`
|
2023-07-02 01:45:18 +02:00
|
|
|
'';
|
2022-05-04 00:29:17 +02:00
|
|
|
|
|
|
|
defaultCursor = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "left_ptr";
|
|
|
|
example = "X_cursor";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The default cursor file to use within the package.";
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
gtk = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption ''
|
2023-07-01 01:30:13 +02:00
|
|
|
gtk config generation for {option}`home.pointerCursor`
|
2023-07-02 01:45:18 +02:00
|
|
|
'';
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
cursorPath = "${cfg.package}/share/icons/${escapeShellArg cfg.name}/cursors/${
|
2022-05-06 03:15:51 +02:00
|
|
|
escapeShellArg cfg.x11.defaultCursor
|
2022-05-04 00:29:17 +02:00
|
|
|
}";
|
|
|
|
|
2023-07-29 04:01:41 +02:00
|
|
|
defaultIndexThemePackage = pkgs.writeTextFile {
|
|
|
|
name = "index.theme";
|
|
|
|
destination = "/share/icons/default/index.theme";
|
|
|
|
# Set name in icons theme, for compatibility with AwesomeWM etc. See:
|
|
|
|
# https://github.com/nix-community/home-manager/issues/2081
|
|
|
|
# https://wiki.archlinux.org/title/Cursor_themes#XDG_specification
|
|
|
|
text = ''
|
|
|
|
[Icon Theme]
|
|
|
|
Name=Default
|
|
|
|
Comment=Default Cursor Theme
|
|
|
|
Inherits=${cfg.name}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-05-04 00:29:17 +02:00
|
|
|
in {
|
2024-07-28 17:58:33 +02:00
|
|
|
meta.maintainers = [ maintainers.league ];
|
2022-05-04 00:29:17 +02:00
|
|
|
|
|
|
|
imports = [
|
2023-07-02 01:45:18 +02:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "package" ] [
|
2022-05-04 00:29:17 +02:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"package"
|
|
|
|
])
|
2023-07-02 01:45:18 +02:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "name" ] [
|
2022-05-04 00:29:17 +02:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"name"
|
|
|
|
])
|
2023-07-02 01:45:18 +02:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "size" ] [
|
2022-05-04 00:29:17 +02:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"size"
|
|
|
|
])
|
2023-07-02 01:45:18 +02:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "defaultCursor" ] [
|
2022-05-04 00:29:17 +02:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"x11"
|
|
|
|
"defaultCursor"
|
|
|
|
])
|
|
|
|
|
|
|
|
({ ... }: {
|
|
|
|
warnings = optional (any (x:
|
|
|
|
getAttrFromPath
|
|
|
|
([ "xsession" "pointerCursor" ] ++ [ x ] ++ [ "isDefined" ])
|
|
|
|
options) [ "package" "name" "size" "defaultCursor" ]) ''
|
|
|
|
The option `xsession.pointerCursor` has been merged into `home.pointerCursor` and will be removed
|
|
|
|
in the future. Please change to set `home.pointerCursor` directly and enable `home.pointerCursor.x11.enable`
|
|
|
|
to generate x11 specific cursor configurations. You can refer to the documentation for more details.
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
home.pointerCursor = mkOption {
|
|
|
|
type = types.nullOr pointerCursorModule;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Cursor configuration. Set to `null` to disable.
|
|
|
|
|
2023-01-24 11:30:04 +01:00
|
|
|
Top-level options declared under this submodule are backend independent
|
2023-07-01 01:30:13 +02:00
|
|
|
options. Options declared under namespaces such as `x11`
|
2022-05-04 00:29:17 +02:00
|
|
|
are backend specific options. By default, only backend independent cursor
|
|
|
|
configurations are generated. If you need configurations for specific
|
2022-08-26 00:07:08 +02:00
|
|
|
backends, you can toggle them via the enable option. For example,
|
2023-07-01 01:30:13 +02:00
|
|
|
[](#opt-home.pointerCursor.x11.enable)
|
2022-08-26 00:07:08 +02:00
|
|
|
will enable x11 cursor configurations.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2023-07-14 21:25:46 +02:00
|
|
|
Note that this will merely generate the cursor configurations.
|
|
|
|
To apply the configurations, the relevant subsytems must also be configured.
|
2023-07-01 01:30:13 +02:00
|
|
|
For example, [](#opt-home.pointerCursor.gtk.enable) will generate
|
|
|
|
the gtk cursor configuration, but [](#opt-gtk.enable) needs
|
2023-07-14 21:25:46 +02:00
|
|
|
to be set for it to be applied.
|
2022-05-04 00:29:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg != null) (mkMerge [
|
|
|
|
{
|
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "home.pointerCursor" pkgs platforms.linux)
|
|
|
|
];
|
|
|
|
|
2023-07-29 04:01:41 +02:00
|
|
|
home.packages = [ cfg.package defaultIndexThemePackage ];
|
2022-05-04 00:29:17 +02:00
|
|
|
|
|
|
|
# Set directory to look for cursors in, needed for some applications
|
|
|
|
# that are unable to find cursors otherwise. See:
|
|
|
|
# https://github.com/nix-community/home-manager/issues/2812
|
|
|
|
# https://wiki.archlinux.org/title/Cursor_themes#Environment_variable
|
|
|
|
home.sessionVariables = {
|
2023-01-03 22:21:40 +01:00
|
|
|
XCURSOR_PATH = mkDefault ("$XCURSOR_PATH\${XCURSOR_PATH:+:}"
|
|
|
|
+ "${config.home.profileDirectory}/share/icons");
|
2023-03-16 10:05:07 +01:00
|
|
|
XCURSOR_SIZE = mkDefault cfg.size;
|
|
|
|
XCURSOR_THEME = mkDefault cfg.name;
|
2022-05-04 00:29:17 +02:00
|
|
|
};
|
2023-07-29 04:01:41 +02:00
|
|
|
|
2023-08-22 01:13:17 +02:00
|
|
|
# Add symlink of cursor icon directory to $HOME/.icons, needed for
|
2023-07-29 04:01:41 +02:00
|
|
|
# backwards compatibility with some applications. See:
|
|
|
|
# https://specifications.freedesktop.org/icon-theme-spec/latest/ar01s03.html
|
2023-08-22 01:13:17 +02:00
|
|
|
home.file.".icons/default/index.theme".source =
|
|
|
|
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
|
|
|
home.file.".icons/${cfg.name}".source =
|
|
|
|
"${cfg.package}/share/icons/${cfg.name}";
|
|
|
|
|
2023-11-06 19:54:36 +01:00
|
|
|
# Add cursor icon link to $XDG_DATA_HOME/icons as well for redundancy.
|
|
|
|
xdg.dataFile."icons/default/index.theme".source =
|
2023-08-22 01:13:17 +02:00
|
|
|
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
2023-11-06 19:54:36 +01:00
|
|
|
xdg.dataFile."icons/${cfg.name}".source =
|
2023-08-22 01:13:17 +02:00
|
|
|
"${cfg.package}/share/icons/${cfg.name}";
|
2022-05-04 00:29:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf cfg.x11.enable {
|
|
|
|
xsession.initExtra = ''
|
|
|
|
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cursorPath} ${
|
|
|
|
toString cfg.size
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
xresources.properties = {
|
|
|
|
"Xcursor.theme" = cfg.name;
|
|
|
|
"Xcursor.size" = cfg.size;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.gtk.enable {
|
|
|
|
gtk.cursorTheme = mkDefault { inherit (cfg) package name size; };
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|