diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0cb5758ec..47efef6a1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -557,6 +557,17 @@ in 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. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index aa04f3271..c179c7325 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -66,6 +66,7 @@ let ./services/window-managers/xmonad.nix ./services/xscreensaver.nix ./systemd.nix + ./xcursor.nix ./xresources.nix ./xsession.nix diff --git a/modules/xcursor.nix b/modules/xcursor.nix new file mode 100644 index 000000000..bb8af9b78 --- /dev/null +++ b/modules/xcursor.nix @@ -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 + xorg.xcursorthemes contains cursors named + whiteglass, redglass, and handhelds. The package + vanilla-dmz 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; + }; + + }; +}