2022-05-03 22:29:17 +00: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-01 23:45:18 +00:00
|
|
|
description = "Package providing the cursor theme.";
|
2022-05-03 22:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "Vanilla-DMZ";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The cursor name within the package.";
|
2022-05-03 22:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 32;
|
|
|
|
example = 64;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The cursor size.";
|
2022-05-03 22:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
x11 = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption ''
|
2023-06-30 23:30:13 +00:00
|
|
|
x11 config generation for {option}`home.pointerCursor`
|
2023-07-01 23:45:18 +00:00
|
|
|
'';
|
2022-05-03 22:29:17 +00:00
|
|
|
|
|
|
|
defaultCursor = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "left_ptr";
|
|
|
|
example = "X_cursor";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The default cursor file to use within the package.";
|
2022-05-03 22:29:17 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
gtk = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption ''
|
2023-06-30 23:30:13 +00:00
|
|
|
gtk config generation for {option}`home.pointerCursor`
|
2023-07-01 23:45:18 +00:00
|
|
|
'';
|
2022-05-03 22:29:17 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
cursorPath = "${cfg.package}/share/icons/${escapeShellArg cfg.name}/cursors/${
|
2022-05-06 01:15:51 +00:00
|
|
|
escapeShellArg cfg.x11.defaultCursor
|
2022-05-03 22:29:17 +00:00
|
|
|
}";
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.polykernel maintainers.league ];
|
|
|
|
|
|
|
|
imports = [
|
2023-07-01 23:45:18 +00:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "package" ] [
|
2022-05-03 22:29:17 +00:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"package"
|
|
|
|
])
|
2023-07-01 23:45:18 +00:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "name" ] [
|
2022-05-03 22:29:17 +00:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"name"
|
|
|
|
])
|
2023-07-01 23:45:18 +00:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "size" ] [
|
2022-05-03 22:29:17 +00:00
|
|
|
"home"
|
|
|
|
"pointerCursor"
|
|
|
|
"size"
|
|
|
|
])
|
2023-07-01 23:45:18 +00:00
|
|
|
(mkAliasOptionModule [ "xsession" "pointerCursor" "defaultCursor" ] [
|
2022-05-03 22:29:17 +00: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-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Cursor configuration. Set to `null` to disable.
|
|
|
|
|
2023-01-24 10:30:04 +00:00
|
|
|
Top-level options declared under this submodule are backend independent
|
2023-06-30 23:30:13 +00:00
|
|
|
options. Options declared under namespaces such as `x11`
|
2022-05-03 22:29:17 +00:00
|
|
|
are backend specific options. By default, only backend independent cursor
|
|
|
|
configurations are generated. If you need configurations for specific
|
2022-08-25 22:07:08 +00:00
|
|
|
backends, you can toggle them via the enable option. For example,
|
2023-06-30 23:30:13 +00:00
|
|
|
[](#opt-home.pointerCursor.x11.enable)
|
2022-08-25 22:07:08 +00:00
|
|
|
will enable x11 cursor configurations.
|
2023-06-30 23:30:13 +00:00
|
|
|
|
2023-07-14 19:25:46 +00:00
|
|
|
Note that this will merely generate the cursor configurations.
|
|
|
|
To apply the configurations, the relevant subsytems must also be configured.
|
2023-06-30 23:30:13 +00:00
|
|
|
For example, [](#opt-home.pointerCursor.gtk.enable) will generate
|
|
|
|
the gtk cursor configuration, but [](#opt-gtk.enable) needs
|
2023-07-14 19:25:46 +00:00
|
|
|
to be set for it to be applied.
|
2022-05-03 22:29:17 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg != null) (mkMerge [
|
|
|
|
{
|
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "home.pointerCursor" pkgs platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
# 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
|
2023-04-11 20:41:48 +00:00
|
|
|
xdg.dataFile."icons/default/index.theme".text = ''
|
2022-05-03 22:29:17 +00:00
|
|
|
[icon theme]
|
|
|
|
Name=Default
|
|
|
|
Comment=Default Cursor Theme
|
|
|
|
Inherits=${cfg.name}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# 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 21:21:40 +00:00
|
|
|
XCURSOR_PATH = mkDefault ("$XCURSOR_PATH\${XCURSOR_PATH:+:}"
|
|
|
|
+ "${config.home.profileDirectory}/share/icons");
|
2023-03-16 09:05:07 +00:00
|
|
|
XCURSOR_SIZE = mkDefault cfg.size;
|
|
|
|
XCURSOR_THEME = mkDefault cfg.name;
|
2022-05-03 22:29:17 +00: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; };
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|