nixos-config/modules/programs/urxvt.nix

170 lines
5.5 KiB
Nix
Raw Normal View History

2019-10-24 02:20:38 +02:00
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.custom.urxvt;
in {
options.programs.custom.urxvt = {
enable = mkEnableOption "configure and enable urxvt";
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
! 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
'';
"X11/Xresource.d/urxvt-font".source = let
fontFamily = "terminus";
normalFont = fontSize: "-*-${fontFamily}-medium-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
boldFont = fontSize: "-*-${fontFamily}-bold-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
italicFont = normalFont;
itallicBoldFont = boldFont;
backupFont = fontSize: "xft:TerminessTTF Nerd Font:pixelsize=${toString fontSize}";
fontCommand = key: fontSize: ''
URxvt.keysym.M-${key}: command:\033]710;${normalFont fontSize},${backupFont fontSize}\007\033]711;${boldFont fontSize},${backupFont fontSize}\007
'';
in pkgs.writeText "Xresource-urxvt-font" ''
URxvt.allow_bold: true
URxvt.xftAntialias: true
!! use xfontsel or fontmatrix to choose line
!URxvt.font: ${normalFont cfg.fontSize},${backupFont cfg.fontSize}
!URxvt.boldFont: ${boldFont cfg.fontSize},${backupFont cfg.fontSize}
!URxvt.italicFont: ${italicFont cfg.fontSize},${backupFont cfg.fontSize}
!URxvt.bolditalicFont: ${itallicBoldFont cfg.fontSize},${backupFont cfg.fontSize}
URxvt.font: ${normalFont cfg.fontSize}
URxvt.boldFont: ${boldFont cfg.fontSize}
URxvt.italicFont: ${italicFont cfg.fontSize}
URxvt.bolditalicFont: ${itallicBoldFont cfg.fontSize}
${fontCommand "F1" cfg.fontSize}
${fontCommand "F2" (cfg.fontSize + 5)}
${fontCommand "F3" (cfg.fontSize + 10)}
${fontCommand "F4" (cfg.fontSize + 20)}
'';
"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
'';
};
};
}