fork/home-manager

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

Robert HelgessonMerge PR #421575790441

master
4.4 KiB156 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.urxvt;
8
9in {
10  options.programs.urxvt = {
11    enable = mkEnableOption "rxvt-unicode terminal emulator";
12
13    package = mkOption {
14      type = types.package;
15      default = pkgs.rxvt-unicode;
16      defaultText = literalExpression "pkgs.rxvt-unicode";
17      description = "rxvt-unicode package to install.";
18    };
19
20    fonts = mkOption {
21      type = types.listOf types.str;
22      default = [ ];
23      description = "List of fonts to be used.";
24      example = [ "xft:Droid Sans Mono Nerd Font:size=9" ];
25    };
26
27    keybindings = mkOption {
28      type = types.attrsOf types.str;
29      default = { };
30      description = "Mapping of keybindings to actions";
31      example = literalExpression ''
32        {
33          "Shift-Control-C" = "eval:selection_to_clipboard";
34          "Shift-Control-V" = "eval:paste_clipboard";
35        }
36      '';
37    };
38
39    iso14755 = mkOption {
40      type = types.bool;
41      default = true;
42      description =
43        "ISO14755 support for viewing and entering unicode characters.";
44    };
45
46    scroll = {
47      bar = mkOption {
48        type = types.submodule {
49          options = {
50            enable = mkOption {
51              type = types.bool;
52              default = true;
53              description = "Whether to enable the scrollbar";
54            };
55
56            style = mkOption {
57              type = types.enum [ "rxvt" "plain" "next" "xterm" ];
58              default = "plain";
59              description = "Scrollbar style.";
60            };
61
62            align = mkOption {
63              type = types.enum [ "top" "bottom" "center" ];
64              default = "center";
65              description = "Scrollbar alignment.";
66            };
67
68            position = mkOption {
69              type = types.enum [ "left" "right" ];
70              default = "right";
71              description = "Scrollbar position.";
72            };
73
74            floating = mkOption {
75              type = types.bool;
76              default = true;
77              description =
78                "Whether to display an rxvt scrollbar without a trough.";
79            };
80          };
81        };
82        default = { };
83        description = "Scrollbar settings.";
84      };
85
86      lines = mkOption {
87        type = types.ints.unsigned;
88        default = 10000;
89        description = "Number of lines to save in the scrollback buffer.";
90      };
91
92      keepPosition = mkOption {
93        type = types.bool;
94        default = true;
95        description =
96          "Whether to keep a scroll position when TTY receives new lines.";
97      };
98
99      scrollOnKeystroke = mkOption {
100        type = types.bool;
101        default = true;
102        description = "Whether to scroll to bottom on keyboard input.";
103      };
104
105      scrollOnOutput = mkOption {
106        type = types.bool;
107        default = false;
108        description = "Whether to scroll to bottom on TTY output.";
109      };
110    };
111
112    transparent = mkOption {
113      type = types.bool;
114      default = false;
115      description = "Whether to enable pseudo-transparency.";
116    };
117
118    shading = mkOption {
119      type = types.ints.between 0 200;
120      default = 100;
121      description =
122        "Darken (0 to 99) or lighten (101 to 200) the transparent background.";
123    };
124
125    extraConfig = mkOption {
126      default = { };
127      type = types.attrsOf types.anything;
128      description = "Additional configuration to add.";
129      example = { "shading" = 15; };
130    };
131
132  };
133
134  config = mkIf cfg.enable {
135    home.packages = [ cfg.package ];
136
137    xresources.properties = {
138      "URxvt.scrollBar" = cfg.scroll.bar.enable;
139      "URxvt.scrollstyle" = cfg.scroll.bar.style;
140      "URxvt.scrollBar_align" = cfg.scroll.bar.align;
141      "URxvt.scrollBar_right" = cfg.scroll.bar.position == "right";
142      "URxvt.scrollBar_floating" = cfg.scroll.bar.floating;
143      "URxvt.saveLines" = cfg.scroll.lines;
144      "URxvt.scrollWithBuffer" = cfg.scroll.keepPosition;
145      "URxvt.scrollTtyKeypress" = cfg.scroll.scrollOnKeystroke;
146      "URxvt.scrollTtyOutput" = cfg.scroll.scrollOnOutput;
147      "URxvt.transparent" = cfg.transparent;
148      "URxvt.shading" = cfg.shading;
149      "URxvt.iso14755" = cfg.iso14755;
150    } // flip mapAttrs' cfg.keybindings
151      (kb: action: nameValuePair "URxvt.keysym.${kb}" action)
152      // optionalAttrs (cfg.fonts != [ ]) {
153        "URxvt.font" = concatStringsSep "," cfg.fonts;
154      } // flip mapAttrs' cfg.extraConfig (k: v: nameValuePair "URxvt.${k}" v);
155  };
156}