fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
6.6 KiB246 linesraw
1{ pkgs, lib }:
2
3with lib;
4
5let
6
7  primitive = with types; oneOf [ bool int float str ];
8
9  rule = types.submodule {
10    freeformType = with types; attrsOf primitive;
11
12    options = {
13      monitor = mkOption {
14        type = types.nullOr types.str;
15        default = null;
16        description = "The monitor where the rule should be applied.";
17        example = "HDMI-0";
18      };
19
20      desktop = mkOption {
21        type = types.nullOr types.str;
22        default = null;
23        description = "The desktop where the rule should be applied.";
24        example = "^8";
25      };
26
27      node = mkOption {
28        type = types.nullOr types.str;
29        default = null;
30        description = "The node where the rule should be applied.";
31        example = "1";
32      };
33
34      state = mkOption {
35        type = types.nullOr
36          (types.enum [ "tiled" "pseudo_tiled" "floating" "fullscreen" ]);
37        default = null;
38        description = "The state in which a new window should spawn.";
39        example = "floating";
40      };
41
42      layer = mkOption {
43        type = types.nullOr (types.enum [ "below" "normal" "above" ]);
44        default = null;
45        description = "The layer where a new window should spawn.";
46        example = "above";
47      };
48
49      splitDir = mkOption {
50        type = types.nullOr (types.enum [ "north" "west" "south" "east" ]);
51        default = null;
52        description = "The direction where the container is going to be split.";
53        example = "south";
54      };
55
56      splitRatio = mkOption {
57        type = types.nullOr types.float;
58        default = null;
59        description = ''
60          The ratio between the new window and the previous existing window in
61          the desktop.
62        '';
63        example = 0.65;
64      };
65
66      hidden = mkOption {
67        type = types.nullOr types.bool;
68        default = null;
69        description = "Whether the node should occupy any space.";
70        example = true;
71      };
72
73      sticky = mkOption {
74        type = types.nullOr types.bool;
75        default = null;
76        description = "Whether the node should stay on the focused desktop.";
77        example = true;
78      };
79
80      private = mkOption {
81        type = types.nullOr types.bool;
82        default = null;
83        description = ''
84          Whether the node should stay in the same tiling position and size.
85        '';
86        example = true;
87      };
88
89      locked = mkOption {
90        type = types.nullOr types.bool;
91        default = null;
92        description = ''
93          Whether the node should ignore {command}`node --close`
94          messages.
95        '';
96        example = true;
97      };
98
99      marked = mkOption {
100        type = types.nullOr types.bool;
101        default = null;
102        description = "Whether the node will be marked for deferred actions.";
103        example = true;
104      };
105
106      center = mkOption {
107        type = types.nullOr types.bool;
108        default = null;
109        description = ''
110          Whether the node will be put in the center, in floating mode.
111        '';
112        example = true;
113      };
114
115      follow = mkOption {
116        type = types.nullOr types.bool;
117        default = null;
118        description = "Whether focus should follow the node when it is moved.";
119        example = true;
120      };
121
122      manage = mkOption {
123        type = types.nullOr types.bool;
124        default = null;
125        description = ''
126          Whether the window should be managed by bspwm. If false, the window
127          will be ignored by bspwm entirely. This is useful for overlay apps,
128          e.g. screenshot tools.
129        '';
130        example = true;
131      };
132
133      focus = mkOption {
134        type = types.nullOr types.bool;
135        default = null;
136        description = "Whether the node should gain focus on creation.";
137        example = true;
138      };
139
140      border = mkOption {
141        type = types.nullOr types.bool;
142        default = null;
143        description = "Whether the node should have border.";
144        example = true;
145      };
146
147      rectangle = mkOption {
148        type = types.nullOr types.str;
149        default = null;
150        description = "The node's geometry, in the format `WxH+X+Y`.";
151        example = "800x600+32+32";
152      };
153    };
154  };
155
156in {
157  xsession.windowManager.bspwm = {
158    enable = mkEnableOption "bspwm window manager";
159
160    package = mkOption {
161      type = types.package;
162      default = pkgs.bspwm;
163      defaultText = literalExpression "pkgs.bspwm";
164      description = "The bspwm package to use.";
165      example = literalExpression "pkgs.bspwm-unstable";
166    };
167
168    settings = mkOption {
169      type = with types; attrsOf (either primitive (listOf primitive));
170      default = { };
171      description = "General settings given to `bspc config`.";
172      example = {
173        "border_width" = 2;
174        "split_ratio" = 0.52;
175        "gapless_monocle" = true;
176      };
177    };
178
179    extraConfig = mkOption {
180      type = types.lines;
181      default = "";
182      description =
183        "Additional shell commands to be run at the end of the config file.";
184      example = ''
185        bspc subscribe all > ~/bspc-report.log &
186      '';
187    };
188
189    extraConfigEarly = mkOption {
190      type = types.lines;
191      default = "";
192      description =
193        "Like extraConfig, except commands are run at the start of the config file.";
194    };
195
196    monitors = mkOption {
197      type = types.attrsOf (types.listOf types.str);
198      default = { };
199      description =
200        "Specifies the names of desktops to create on each monitor.";
201      example = { "HDMI-0" = [ "web" "terminal" "III" "IV" ]; };
202    };
203
204    alwaysResetDesktops = mkOption {
205      type = types.bool;
206      default = true;
207      description = ''
208        If set to `true`, desktops configured in {option}`monitors` will be reset
209        every time the config is run.
210
211        If set to `false`, desktops will only be configured the first time the config is run.
212        This is useful if you want to dynamically add desktops and you don't want them to be destroyed if you
213        re-run `bspwmrc`.
214      '';
215    };
216
217    rules = mkOption {
218      type = types.attrsOf rule;
219      default = { };
220      description =
221        "Rule configuration. The keys of the attribute set are the targets of the rules.";
222      example = literalExpression ''
223        {
224          "Gimp" = {
225            desktop = "^8";
226            state = "floating";
227            follow = true;
228          };
229          "Kupfer.py" = {
230            focus = true;
231          };
232          "Screenkey" = {
233            manage = false;
234          };
235        }
236      '';
237    };
238
239    startupPrograms = mkOption {
240      type = types.listOf types.str;
241      default = [ ];
242      description = "Programs to be executed during startup.";
243      example = [ "numlockx on" "tilda" ];
244    };
245  };
246}