xcursor: add module

This is a new module for configuring the X cursor theme.
This commit is contained in:
Christopher League 2018-02-01 23:37:45 -05:00 committed by Robert Helgesson
parent 6cca1fc512
commit 563a20fc82
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
3 changed files with 88 additions and 0 deletions

View file

@ -557,6 +557,17 @@ in
A new module is available: 'services.stalonetray' A new module is available: 'services.stalonetray'
''; '';
} }
{
time = "2018-02-04T22:58:49+00:00";
condition = config.xsession.enable;
message = ''
A new option 'xsession.pointerCursor' is now available. It
allows specifying the pointer cursor theme and size. The
settings will be applied in the xsession, Xresources, and
GTK configurations.
'';
}
]; ];
}; };
} }

View file

@ -66,6 +66,7 @@ let
./services/window-managers/xmonad.nix ./services/window-managers/xmonad.nix
./services/xscreensaver.nix ./services/xscreensaver.nix
./systemd.nix ./systemd.nix
./xcursor.nix
./xresources.nix ./xresources.nix
./xsession.nix ./xsession.nix
<nixpkgs/nixos/modules/misc/assertions.nix> <nixpkgs/nixos/modules/misc/assertions.nix>

76
modules/xcursor.nix Normal file
View file

@ -0,0 +1,76 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.xsession.pointerCursor;
cursorType = types.submodule {
options = {
package = mkOption {
type = types.package;
example = literalExample "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.";
};
};
};
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) {
home.packages = [cfg.package];
xsession.initExtra = ''
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cfg.package}/share/icons/${cfg.name}/cursors/X_cursor ${toString cfg.size}
'';
xresources.properties = {
"Xcursor.theme" = cfg.name;
"Xcursor.size" = cfg.size;
};
gtk.gtk2.extraConfig = ''
gtk-cursor-theme-name="${cfg.name}"
gtk-cursor-theme-size=${toString cfg.size}
'';
gtk.gtk3.extraConfig = {
"gtk-cursor-theme-name" = cfg.name;
"gtk-cursor-theme-size" = cfg.size;
};
};
}