aboutsummaryrefslogtreecommitdiff
path: root/modules/xcursor.nix
blob: 63ceef387df816b528dafdea0fb40780f68c0779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ 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.";
      };

      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) {

    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;
    };

    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;
    };

  };
}