home-manager/modules/xcursor.nix
polykernel e01facc340
gtk: add cursor theme configuration (#2481)
* gtk: add cursor theme configuration

- Added the `cursorTheme` under the gtk module.
- Added tests for the gtk3 settings file generation, and renamed
  the gtk2 unit test expected file for clarity.
- Added guard against generating a blank `gtk.css` when `cfg.extraCss`
  is empty.
- Replaced `concatMapStrings` calls with `concatStringsSep`. The library function
  `concatMapStrings` generates an intemediate list which is then passed to
  `concatStringsSep`, As we are not performing other transformation except
  the addition of newlines, a direct call to `concatStringsSep` is sufficient.
- Updated description of examples to be more general "~/.config" -> "$XDG_CONFIG_HOME".
- Update helper functions `toGtk3Ini` and `formatGtk2Option` to use the library
  function `boolToString` and escape the separator in the key name.

* xcursor: delegate GTK cursor settings to gtk.cursorTheme

- Added deprecation warning for GTK settings in the `xsession.cursorTheme` module.
- Modified config section to use `gtk.cursorTheme` for GTK cursor settings.
2022-03-17 15:30:48 -04:00

95 lines
2.5 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.xsession.pointerCursor;
cursorType = types.submodule {
options = {
package = mkOption {
type = types.package;
example = literalExpression "pkgs.vanilla-dmz";
description = "Package providing the cursor theme.";
};
name = mkOption {
type = types.str;
example = "Vanilla-DMZ";
description = "The cursor name within the package.";
};
size = mkOption {
type = types.int;
default = 32;
example = 64;
description = "The cursor size.";
};
defaultCursor = mkOption {
type = types.str;
default = "left_ptr";
example = "X_cursor";
description = "The default cursor file to use within the package.";
};
};
};
in {
meta.maintainers = [ maintainers.league ];
options = {
xsession.pointerCursor = mkOption {
type = types.nullOr cursorType;
default = null;
description = ''
The X cursor theme and settings. The package
<varname>xorg.xcursorthemes</varname> contains cursors named
whiteglass, redglass, and handhelds. The package
<varname>vanilla-dmz</varname> contains cursors named Vanilla-DMZ
and Vanilla-DMZ-AA. Note: handhelds does not seem to work at
custom sizes.
'';
};
};
config = mkIf (cfg != null) {
assertions = [
(hm.assertions.assertPlatform "xsession.pointerCursor" pkgs
platforms.linux)
];
warnings = [''
GTK cursor settings will no longer be handled in the xsession.pointerCursor module in future.
Please use gtk.cursorTheme for GTK cursor settings instead.
''];
home.packages = [ cfg.package ];
xsession.initExtra = ''
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cfg.package}/share/icons/${cfg.name}/cursors/${cfg.defaultCursor} ${
toString cfg.size
}
'';
xresources.properties = {
"Xcursor.theme" = cfg.name;
"Xcursor.size" = cfg.size;
};
# TODO: deprecate after next version release.
gtk.cursorTheme = { inherit (cfg) package name size; };
# 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
home.file.".icons/default/index.theme".text = ''
[icon theme]
Name=Default
Comment=Default Cursor Theme
Inherits=${cfg.name}
'';
};
}