aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/services/window-managers/bspwm/options.nix
blob: 58a58a1a782a01e3200ac6789f3d111a7ae2bebe (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
{ pkgs, lib }:

with lib;

let

  rule = types.submodule {
    options = {
      monitor = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = "The monitor where the rule should be applied.";
        example = "HDMI-0";
      };

      desktop = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = "The desktop where the rule should be applied.";
        example = "^8";
      };

      node = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = "The node where the rule should be applied.";
        example = "1";
      };

      state = mkOption {
        type = types.nullOr
          (types.enum [ "tiled" "pseudo_tiled" "floating" "fullscreen" ]);
        default = null;
        description = "The state in which a new window should spawn.";
        example = "floating";
      };

      layer = mkOption {
        type = types.nullOr (types.enum [ "below" "normal" "above" ]);
        default = null;
        description = "The layer where a new window should spawn.";
        example = "above";
      };

      splitDir = mkOption {
        type = types.nullOr (types.enum [ "north" "west" "south" "east" ]);
        default = null;
        description = "The direction where the container is going to be split.";
        example = "south";
      };

      splitRatio = mkOption {
        type = types.nullOr types.float;
        default = null;
        description = ''
          The ratio between the new window and the previous existing window in
          the desktop.
        '';
        example = 0.65;
      };

      hidden = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether the node should occupy any space.";
        example = true;
      };

      sticky = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether the node should stay on the focused desktop.";
        example = true;
      };

      private = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = ''
          Whether the node should stay in the same tiling position and size.
        '';
        example = true;
      };

      locked = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = ''
          Whether the node should ignore <command>node --close</command>
          messages.
        '';
        example = true;
      };

      marked = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether the node will be marked for deferred actions.";
        example = true;
      };

      center = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = ''
          Whether the node will be put in the center, in floating mode.
        '';
        example = true;
      };

      follow = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether focus should follow the node when it is moved.";
        example = true;
      };

      manage = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = ''
          Whether the window should be managed by bspwm. If false, the window
          will be ignored by bspwm entirely. This is useful for overlay apps,
          e.g. screenshot tools.
        '';
        example = true;
      };

      focus = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether the node should gain focus on creation.";
        example = true;
      };

      border = mkOption {
        type = types.nullOr types.bool;
        default = null;
        description = "Whether the node should have border.";
        example = true;
      };
    };
  };

in {
  xsession.windowManager.bspwm = {
    enable = mkEnableOption "bspwm window manager.";

    package = mkOption {
      type = types.package;
      default = pkgs.bspwm;
      defaultText = literalExample "pkgs.bspwm";
      description = "bspwm package to use.";
      example = literalExample "pkgs.bspwm-unstable";
    };

    settings = mkOption {
      type = with types;
        let primitive = either bool (either int (either float str));
        in attrsOf (either primitive (listOf primitive));
      default = { };
      description = "bspwm configuration";
      example = {
        "border_width" = 2;
        "split_ratio" = 0.52;
        "gapless_monocle" = true;
      };
    };

    extraConfig = mkOption {
      type = types.lines;
      default = "";
      description = "Additional configuration to add.";
      example = ''
        bspc subscribe all > ~/bspc-report.log &
      '';
    };

    monitors = mkOption {
      type = types.attrsOf (types.listOf types.str);
      default = { };
      description = "bspc monitor configurations";
      example = { "HDMI-0" = [ "web" "terminal" "III" "IV" ]; };
    };

    rules = mkOption {
      type = types.attrsOf rule;
      default = { };
      description = "bspc rules";
      example = literalExample ''
        {
          "Gimp" = {
            desktop = "^8";
            state = "floating";
            follow = true;
          };
          "Kupfer.py" = {
            focus = true;
          };
          "Screenkey" = {
            manage = false;
          };
        }
      '';
    };

    startupPrograms = mkOption {
      type = types.listOf types.str;
      default = [ ];
      description = "Programs to be executed during startup.";
      example = [ "numlockx on" "tilda" ];
    };
  };
}