1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-27 04:09:47 +01:00
home-manager/modules/programs/urxvt.nix

157 lines
4.4 KiB
Nix
Raw Normal View History

2018-10-14 12:11:00 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.urxvt;
2020-02-02 00:39:17 +01:00
in {
2018-10-14 12:11:00 +02:00
options.programs.urxvt = {
enable = mkEnableOption "rxvt-unicode terminal emulator";
2018-10-14 12:11:00 +02:00
package = mkOption {
type = types.package;
2022-09-27 00:38:57 +02:00
default = pkgs.rxvt-unicode;
defaultText = literalExpression "pkgs.rxvt-unicode";
description = "rxvt-unicode package to install.";
2018-10-14 12:11:00 +02:00
};
fonts = mkOption {
type = types.listOf types.str;
2020-02-02 00:39:17 +01:00
default = [ ];
description = "List of fonts to be used.";
2018-10-14 12:11:00 +02:00
example = [ "xft:Droid Sans Mono Nerd Font:size=9" ];
};
keybindings = mkOption {
type = types.attrsOf types.str;
2020-02-02 00:39:17 +01:00
default = { };
description = "Mapping of keybindings to actions";
example = literalExpression ''
2018-10-14 12:11:00 +02:00
{
"Shift-Control-C" = "eval:selection_to_clipboard";
"Shift-Control-V" = "eval:paste_clipboard";
}
'';
};
iso14755 = mkOption {
type = types.bool;
default = true;
description =
2020-02-02 00:39:17 +01:00
"ISO14755 support for viewing and entering unicode characters.";
2018-10-14 12:11:00 +02:00
};
scroll = {
bar = mkOption {
type = types.submodule {
options = {
enable = mkOption {
type = types.bool;
default = true;
description = "Whether to enable the scrollbar";
2018-10-14 12:11:00 +02:00
};
style = mkOption {
type = types.enum [ "rxvt" "plain" "next" "xterm" ];
default = "plain";
description = "Scrollbar style.";
2018-10-14 12:11:00 +02:00
};
align = mkOption {
type = types.enum [ "top" "bottom" "center" ];
default = "center";
description = "Scrollbar alignment.";
2018-10-14 12:11:00 +02:00
};
position = mkOption {
type = types.enum [ "left" "right" ];
default = "right";
description = "Scrollbar position.";
2018-10-14 12:11:00 +02:00
};
floating = mkOption {
type = types.bool;
default = true;
description =
2020-02-02 00:39:17 +01:00
"Whether to display an rxvt scrollbar without a trough.";
2018-10-14 12:11:00 +02:00
};
};
};
2020-02-02 00:39:17 +01:00
default = { };
description = "Scrollbar settings.";
2018-10-14 12:11:00 +02:00
};
lines = mkOption {
type = types.ints.unsigned;
default = 10000;
description = "Number of lines to save in the scrollback buffer.";
2018-10-14 12:11:00 +02:00
};
keepPosition = mkOption {
type = types.bool;
default = true;
description =
2020-02-02 00:39:17 +01:00
"Whether to keep a scroll position when TTY receives new lines.";
2018-10-14 12:11:00 +02:00
};
scrollOnKeystroke = mkOption {
type = types.bool;
default = true;
description = "Whether to scroll to bottom on keyboard input.";
2018-10-14 12:11:00 +02:00
};
scrollOnOutput = mkOption {
type = types.bool;
default = false;
description = "Whether to scroll to bottom on TTY output.";
2018-10-14 12:11:00 +02:00
};
};
transparent = mkOption {
type = types.bool;
default = false;
description = "Whether to enable pseudo-transparency.";
2018-10-14 12:11:00 +02:00
};
shading = mkOption {
type = types.ints.between 0 200;
default = 100;
description =
"Darken (0 to 99) or lighten (101 to 200) the transparent background.";
2018-10-14 12:11:00 +02:00
};
extraConfig = mkOption {
2020-02-02 00:39:17 +01:00
default = { };
type = types.attrsOf types.anything;
description = "Additional configuration to add.";
2018-10-14 12:11:00 +02:00
example = { "shading" = 15; };
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xresources.properties = {
"URxvt.scrollBar" = cfg.scroll.bar.enable;
"URxvt.scrollstyle" = cfg.scroll.bar.style;
"URxvt.scrollBar_align" = cfg.scroll.bar.align;
"URxvt.scrollBar_right" = cfg.scroll.bar.position == "right";
"URxvt.scrollBar_floating" = cfg.scroll.bar.floating;
"URxvt.saveLines" = cfg.scroll.lines;
"URxvt.scrollWithBuffer" = cfg.scroll.keepPosition;
"URxvt.scrollTtyKeypress" = cfg.scroll.scrollOnKeystroke;
"URxvt.scrollTtyOutput" = cfg.scroll.scrollOnOutput;
"URxvt.transparent" = cfg.transparent;
"URxvt.shading" = cfg.shading;
"URxvt.iso14755" = cfg.iso14755;
2020-02-02 00:39:17 +01:00
} // flip mapAttrs' cfg.keybindings
(kb: action: nameValuePair "URxvt.keysym.${kb}" action)
// optionalAttrs (cfg.fonts != [ ]) {
"URxvt.font" = concatStringsSep "," cfg.fonts;
} // flip mapAttrs' cfg.extraConfig (k: v: nameValuePair "URxvt.${k}" v);
2018-10-14 12:11:00 +02:00
};
}