1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-30 18:38:31 +02:00
home-manager/modules/config/home-cursor.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

166 lines
5.0 KiB
Nix

{ 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";
description = lib.mdDoc "Package providing the cursor theme.";
};
name = mkOption {
type = types.str;
example = "Vanilla-DMZ";
description = lib.mdDoc "The cursor name within the package.";
};
size = mkOption {
type = types.int;
default = 32;
example = 64;
description = lib.mdDoc "The cursor size.";
};
x11 = {
enable = mkEnableOption (lib.mdDoc ''
x11 config generation for {option}`home.pointerCursor`
'');
defaultCursor = mkOption {
type = types.str;
default = "left_ptr";
example = "X_cursor";
description =
lib.mdDoc "The default cursor file to use within the package.";
};
};
gtk = {
enable = mkEnableOption (lib.mdDoc ''
gtk config generation for {option}`home.pointerCursor`
'');
};
};
};
cursorPath = "${cfg.package}/share/icons/${escapeShellArg cfg.name}/cursors/${
escapeShellArg cfg.x11.defaultCursor
}";
in {
meta.maintainers = [ maintainers.polykernel maintainers.league ];
imports = [
(mkAliasOptionModuleMD [ "xsession" "pointerCursor" "package" ] [
"home"
"pointerCursor"
"package"
])
(mkAliasOptionModuleMD [ "xsession" "pointerCursor" "name" ] [
"home"
"pointerCursor"
"name"
])
(mkAliasOptionModuleMD [ "xsession" "pointerCursor" "size" ] [
"home"
"pointerCursor"
"size"
])
(mkAliasOptionModuleMD [ "xsession" "pointerCursor" "defaultCursor" ] [
"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;
description = lib.mdDoc ''
Cursor configuration. Set to `null` to disable.
Top-level options declared under this submodule are backend independent
options. Options declared under namespaces such as `x11`
are backend specific options. By default, only backend independent cursor
configurations are generated. If you need configurations for specific
backends, you can toggle them via the enable option. For example,
[](#opt-home.pointerCursor.x11.enable)
will enable x11 cursor configurations.
Note that this will merely generate the cursor configurations.
To apply the configurations, the relevant subsytems must also be configured.
For example, [](#opt-home.pointerCursor.gtk.enable) will generate
the gtk cursor configuration, but [](#opt-gtk.enable) needs
to be set for it to be applied.
'';
};
};
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
xdg.dataFile."icons/default/index.theme".text = ''
[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 = {
XCURSOR_PATH = mkDefault ("$XCURSOR_PATH\${XCURSOR_PATH:+:}"
+ "${config.home.profileDirectory}/share/icons");
XCURSOR_SIZE = mkDefault cfg.size;
XCURSOR_THEME = mkDefault cfg.name;
};
}
(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; };
})
]);
}