fork/home-manager

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

Robert HelgessonMerge PR #421575790441

master
11.4 KiB381 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.termite;
8
9in {
10  options = {
11    programs.termite = {
12      enable = mkEnableOption "Termite VTE-based terminal";
13
14      allowBold = mkOption {
15        default = null;
16        type = types.nullOr types.bool;
17        description = ''
18          Allow the output of bold characters when the bold escape sequence appears.
19        '';
20      };
21
22      audibleBell = mkOption {
23        default = null;
24        type = types.nullOr types.bool;
25        description = "Have the terminal beep on the terminal bell.";
26      };
27
28      clickableUrl = mkOption {
29        default = null;
30        type = types.nullOr types.bool;
31        description = ''
32          Auto-detected URLs can be clicked on to open them in  your browser.
33          Only enabled if a browser is configured or detected.
34        '';
35      };
36
37      dynamicTitle = mkOption {
38        default = null;
39        type = types.nullOr types.bool;
40        description = ''
41          Settings dynamic title allows the terminal and the shell to
42          update the terminal's title.
43        '';
44      };
45
46      enableVteIntegration = mkEnableOption "Shell VTE integration" // {
47        default = true;
48      };
49
50      fullscreen = mkOption {
51        default = null;
52        type = types.nullOr types.bool;
53        description = "Enables entering fullscreen mode by pressing F11.";
54      };
55
56      mouseAutohide = mkOption {
57        default = null;
58        type = types.nullOr types.bool;
59        description = ''
60          Automatically hide the mouse pointer when you start typing.
61        '';
62      };
63
64      scrollOnOutput = mkOption {
65        default = null;
66        type = types.nullOr types.bool;
67        description = "Scroll to the bottom when the shell generates output.";
68      };
69
70      scrollOnKeystroke = mkOption {
71        default = null;
72        type = types.nullOr types.bool;
73        description = ''
74          Scroll to the bottom automatically when a key is pressed.
75        '';
76      };
77
78      searchWrap = mkOption {
79        default = null;
80        type = types.nullOr types.bool;
81        description = "Search from top again when you hit the bottom.";
82      };
83
84      urgentOnBell = mkOption {
85        default = null;
86        type = types.nullOr types.bool;
87        description = "Sets the window as urgent on the terminal bell.";
88      };
89
90      font = mkOption {
91        default = null;
92        example = "Monospace 12";
93        type = types.nullOr types.str;
94        description = "The font description for the terminal's font.";
95      };
96
97      geometry = mkOption {
98        default = null;
99        example = "640x480";
100        type = types.nullOr types.str;
101        description = "The default window geometry for new terminal windows.";
102      };
103
104      iconName = mkOption {
105        default = null;
106        example = "terminal";
107        type = types.nullOr types.str;
108        description =
109          "The name of the icon to be used for the terminal process.";
110      };
111
112      scrollbackLines = mkOption {
113        default = null;
114        example = 10000;
115        type = types.nullOr types.int;
116        description =
117          "Set the number of lines to limit the terminal's scrollback.";
118      };
119
120      browser = mkOption {
121        default = null;
122        type = types.nullOr types.str;
123        example = "${pkgs.xdg-utils}/xdg-open";
124        description = ''
125          Set the default browser for opening links. If its not set, $BROWSER is read.
126          If that's not set, url hints will be disabled.
127        '';
128      };
129
130      cursorBlink = mkOption {
131        default = null;
132        example = "system";
133        type = types.nullOr (types.enum [ "system" "on" "off" ]);
134        description = ''
135          Specify the how the terminal's cursor should behave.
136          Accepts system to respect the gtk global configuration,
137          on and off to explicitly enable or disable them.
138        '';
139      };
140
141      cursorShape = mkOption {
142        default = null;
143        example = "block";
144        type = types.nullOr (types.enum [ "block" "underline" "ibeam" ]);
145        description = ''
146          Specify how the cursor should look. Accepts block, ibeam and underline.
147        '';
148      };
149
150      filterUnmatchedUrls = mkOption {
151        default = null;
152        type = types.nullOr types.bool;
153        description =
154          "Whether to hide url hints not matching input in url hints mode.";
155      };
156
157      modifyOtherKeys = mkOption {
158        default = null;
159        type = types.nullOr types.bool;
160        description = ''
161          Emit escape sequences for extra keys,
162          like the modifyOtherKeys resource for
163          {manpage}`xterm(1)`.
164        '';
165      };
166
167      sizeHints = mkOption {
168        default = null;
169        type = types.nullOr types.bool;
170        description = ''
171          Enable size hints. Locks the terminal resizing
172          to increments of the terminal's cell size.
173          Requires a window manager that respects scroll hints.
174        '';
175      };
176
177      scrollbar = mkOption {
178        default = null;
179        type = types.nullOr (types.enum [ "off" "left" "right" ]);
180        description = "Scrollbar position.";
181      };
182
183      backgroundColor = mkOption {
184        default = null;
185        example = "rgba(63, 63, 63, 0.8)";
186        type = types.nullOr types.str;
187        description = "Background color value.";
188      };
189
190      cursorColor = mkOption {
191        default = null;
192        example = "#dcdccc";
193        type = types.nullOr types.str;
194        description = "Cursor color value.";
195      };
196
197      cursorForegroundColor = mkOption {
198        default = null;
199        example = "#dcdccc";
200        type = types.nullOr types.str;
201        description = "Cursor foreground color value.";
202      };
203
204      foregroundColor = mkOption {
205        default = null;
206        example = "#dcdccc";
207        type = types.nullOr types.str;
208        description = "Foreground color value.";
209      };
210
211      foregroundBoldColor = mkOption {
212        default = null;
213        example = "#ffffff";
214        type = types.nullOr types.str;
215        description = "Foreground bold color value.";
216      };
217
218      highlightColor = mkOption {
219        default = null;
220        example = "#2f2f2f";
221        type = types.nullOr types.str;
222        description = "highlight color value.";
223      };
224
225      hintsActiveBackgroundColor = mkOption {
226        default = null;
227        example = "#3f3f3f";
228        type = types.nullOr types.str;
229        description = "Hints active background color value.";
230      };
231
232      hintsActiveForegroundColor = mkOption {
233        default = null;
234        example = "#e68080";
235        type = types.nullOr types.str;
236        description = "Hints active foreground color value.";
237      };
238
239      hintsBackgroundColor = mkOption {
240        default = null;
241        example = "#3f3f3f";
242        type = types.nullOr types.str;
243        description = "Hints background color value.";
244      };
245
246      hintsForegroundColor = mkOption {
247        default = null;
248        example = "#dcdccc";
249        type = types.nullOr types.str;
250        description = "Hints foreground color value.";
251      };
252
253      hintsBorderColor = mkOption {
254        default = null;
255        example = "#3f3f3f";
256        type = types.nullOr types.str;
257        description = "Hints border color value.";
258      };
259
260      hintsBorderWidth = mkOption {
261        default = null;
262        example = "0.5";
263        type = types.nullOr types.str;
264        description = "Hints border width.";
265      };
266
267      hintsFont = mkOption {
268        default = null;
269        example = "Monospace 12";
270        type = types.nullOr types.str;
271        description = "The font description for the hints font.";
272      };
273
274      hintsPadding = mkOption {
275        default = null;
276        example = 2;
277        type = types.nullOr types.int;
278        description = "Hints padding.";
279      };
280
281      hintsRoundness = mkOption {
282        default = null;
283        example = "0.2";
284        type = types.nullOr types.str;
285        description = "Hints roundness.";
286      };
287
288      optionsExtra = mkOption {
289        default = "";
290        example = "fullscreen = true";
291        type = types.lines;
292        description =
293          "Extra options that should be added to [options] section.";
294      };
295
296      colorsExtra = mkOption {
297        default = "";
298        example = ''
299          color0 = #3f3f3f
300          color1 = #705050
301          color2 = #60b48a
302        '';
303        type = types.lines;
304        description =
305          "Extra colors options that should be added to [colors] section.";
306      };
307
308      hintsExtra = mkOption {
309        default = "";
310        example = "border = #3f3f3f";
311        type = types.lines;
312        description =
313          "Extra hints options that should be added to [hints] section.";
314      };
315    };
316  };
317
318  config = (let
319    boolToString = v: if v then "true" else "false";
320    optionalBoolean = name: val:
321      lib.optionalString (val != null) "${name} = ${boolToString val}";
322    optionalInteger = name: val:
323      lib.optionalString (val != null) "${name} = ${toString val}";
324    optionalString = name: val:
325      lib.optionalString (val != null) "${name} = ${val}";
326  in mkIf cfg.enable {
327    home.packages = [ pkgs.termite ];
328    xdg.configFile."termite/config".text = ''
329      [options]
330      ${optionalBoolean "allow_bold" cfg.allowBold}
331      ${optionalBoolean "audible_bell" cfg.audibleBell}
332      ${optionalString "browser" cfg.browser}
333      ${optionalBoolean "clickable_url" cfg.clickableUrl}
334      ${optionalString "cursor_blink" cfg.cursorBlink}
335      ${optionalString "cursor_shape" cfg.cursorShape}
336      ${optionalBoolean "dynamic_title" cfg.dynamicTitle}
337      ${optionalBoolean "filter_unmatched_urls" cfg.filterUnmatchedUrls}
338      ${optionalString "font" cfg.font}
339      ${optionalBoolean "fullscreen" cfg.fullscreen}
340      ${optionalString "geometry" cfg.geometry}
341      ${optionalString "icon_name" cfg.iconName}
342      ${optionalBoolean "modify_other_keys" cfg.modifyOtherKeys}
343      ${optionalBoolean "mouse_autohide" cfg.mouseAutohide}
344      ${optionalBoolean "scroll_on_keystroke" cfg.scrollOnKeystroke}
345      ${optionalBoolean "scroll_on_output" cfg.scrollOnOutput}
346      ${optionalInteger "scrollback_lines" cfg.scrollbackLines}
347      ${optionalString "scrollbar" cfg.scrollbar}
348      ${optionalBoolean "search_wrap" cfg.searchWrap}
349      ${optionalBoolean "size_hints" cfg.sizeHints}
350      ${optionalBoolean "urgent_on_bell" cfg.urgentOnBell}
351
352      ${cfg.optionsExtra}
353
354      [colors]
355      ${optionalString "background" cfg.backgroundColor}
356      ${optionalString "cursor" cfg.cursorColor}
357      ${optionalString "cursor_foreground" cfg.cursorForegroundColor}
358      ${optionalString "foreground" cfg.foregroundColor}
359      ${optionalString "foreground_bold" cfg.foregroundBoldColor}
360      ${optionalString "highlight" cfg.highlightColor}
361
362      ${cfg.colorsExtra}
363
364      [hints]
365      ${optionalString "active_background" cfg.hintsActiveBackgroundColor}
366      ${optionalString "active_foreground" cfg.hintsActiveForegroundColor}
367      ${optionalString "background" cfg.hintsBackgroundColor}
368      ${optionalString "border" cfg.hintsBorderColor}
369      ${optionalInteger "border_width" cfg.hintsBorderWidth}
370      ${optionalString "font" cfg.hintsFont}
371      ${optionalString "foreground" cfg.hintsForegroundColor}
372      ${optionalInteger "padding" cfg.hintsPadding}
373      ${optionalInteger "roundness" cfg.hintsRoundness}
374
375      ${cfg.hintsExtra}
376    '';
377
378    programs.bash.enableVteIntegration = lib.mkDefault cfg.enableVteIntegration;
379    programs.zsh.enableVteIntegration = lib.mkDefault cfg.enableVteIntegration;
380  });
381}