{ config, pkgs, lib, ... }: # find all URXVT parameters with # urxvt --help 2>&1| sed -n '/: /s/^ */! URxvt*/gp' | les with lib; let cfg = config.programs.custom.urxvt; in { options.programs.custom.urxvt = { enable = mkEnableOption "configure and enable urxvt"; fontType = mkOption { type = types.enum [ "bitmap" "vector" ]; default = "bitmap"; }; fontSize = mkOption { type = types.int; default = 17; description = '' size of the terminal font ''; }; colorTheme = mkOption { type = types.enum [ "dark" "light" ]; default = "dark"; description = '' solarized color theme ''; }; }; config = mkIf cfg.enable { environment.systemPackages = [ pkgs.rxvt_unicode ]; environment.etc = { "X11/Xresource.d/urxvt".source = pkgs.writeText "Xresource-urxvt" '' !! Perl extensions !! --------------- URxvt.perl-ext-common: default,matcher,selection-to-clipboard ! Urgency URxvt.urgentOnBell: true !! Highlight URLs !! -------------- URxvt.url-launcher: /run/current-system/sw/bin/browser-select URxvt.matcher.button: 1 !! History !! ------- URxvt.scrollStyle: rxvt URxvt.scrollBar: false URxvt.saveLines: 1000000 !! Color Configuration !! ------------------- !! do not graded out unselected shells !! ----------------------------------- URxvt.fading: 0 !! copy on select !! -------------- URxvt.clipboard.autocopy: true ''; "X11/Xresource.d/urxvt-font".source = let bitmapPart = let # use xfontsel or fontmatrix to choose line fontFamily = "terminus"; normalFont = fontSize: "-*-${fontFamily}-medium-*-*-*-${toString fontSize}-*-*-*-*-*-*-*"; boldFont = fontSize: "-*-${fontFamily}-bold-*-*-*-${toString fontSize}-*-*-*-*-*-*-*"; italicFont = normalFont; itallicBoldFont = boldFont; in '' URxvt.font: ${normalFont cfg.fontSize} URxvt.boldFont: ${boldFont cfg.fontSize} URxvt.italicFont: ${italicFont cfg.fontSize} URxvt.bolditalicFont: ${itallicBoldFont cfg.fontSize} ''; vectorPart = let # show available fonts = `fc-list` backupFont = fontSize: style: #"xft:TerminessTTF Nerd Font:pixelsize=${toString fontSize}"; "xft:JetBrains Mono:pixelsize=${toString fontSize}${optionalString (style != null) ",style:${style}"}"; in '' URxvt.font: ${backupFont cfg.fontSize null} URxvt.boldFont: ${backupFont cfg.fontSize "Bold"} URxvt.italicFont: ${backupFont cfg.fontSize "Italic"} URxvt.bolditalicFont: ${backupFont cfg.fontSize "Bold Italic"} ''; in pkgs.writeText "Xresource-urxvt-font" '' URxvt.allow_bold: true URxvt.xftAntialias: true ${optionalString (cfg.fontType == "bitmap") bitmapPart} ${optionalString (cfg.fontType == "vector") vectorPart} ''; "X11/Xresource.d/urxvt-colors".source = let colorTheme = if (cfg.colorTheme == "dark") then '' #define S_base03 #002b36 #define S_base02 #073642 #define S_base01 #586e75 #define S_base00 #657b83 #define S_base0 #839496 #define S_base1 #93a1a1 #define S_base2 #eee8d5 #define S_base3 #fdf6e3 '' else '' #define S_base03 #fdf6e3 #define S_base02 #eee8d5 #define S_base01 #93a1a1 #define S_base00 #839496 #define S_base0 #657b83 #define S_base1 #586e75 #define S_base2 #073642 #define S_base3 #002b36 ''; in pkgs.writeText "Xresource-urxvt-colors" '' !! Common !! ------ #define S_yellow #b58900 #define S_orange #cb4b16 #define S_red #dc322f #define S_magenta #d33682 #define S_violet #6c71c4 #define S_blue #268bd2 #define S_cyan #2aa198 #define S_green #859900 !! ColorTheme !! ---------- ${colorTheme} URxvt*background: S_base03 URxvt*foreground: S_base0 URxvt*fading: 40 URxvt*fadeColor: S_base03 URxvt*cursorColor: S_base1 URxvt*pointerColorBackground: S_base01 URxvt*pointerColorForeground: S_base1 URxvt*color0: S_base02 URxvt*color1: S_red URxvt*color2: S_green URxvt*color3: S_yellow URxvt*color4: S_blue URxvt*color5: S_magenta URxvt*color6: S_cyan URxvt*color7: S_base2 URxvt*color9: S_orange URxvt*color8: S_base03 URxvt*color10: S_base01 URxvt*color11: S_base00 URxvt*color12: S_base0 URxvt*color13: S_violet URxvt*color14: S_base1 URxvt*color15: S_base3 !! fix tasksh gray6 : https://github.com/GothenburgBitFactory/libshared/blob/f1a3cd6bfabfb083fe3c26f580a15c0d60a92ee9/src/Color.cpp#L179 URxvt*color232: S_base03 URxvt*color233: S_base03 URxvt*color234: S_base03 URxvt*color235: S_base03 URxvt*color236: S_base03 URxvt*color237: S_base03 URxvt*color238: S_base03 URxvt*color239: S_base03 URxvt*color240: S_base03 URxvt*color241: S_base03 URxvt*color242: S_base03 ''; }; }; }