nixos-config/modules/programs/xterm.nix

145 lines
4.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.xterm;
in {
options.programs.custom.xterm= {
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.xterm ];
environment.etc = {
"X11/Xresource.d/xterm".source = pkgs.writeText "Xresource-xterm" ''
XTerm*termName: xterm-256color
XTerm*selectToClipboard: true
XTerm.*.bellIsUrgent: true
'';
"X11/Xresource.d/xterm-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}";
in pkgs.writeText "Xresource-xterm-font" ''
XTerm.allow_bold: true
XTerm.xftAntialias: true
!! use xfontsel or fontmatrix to choose line
!XTerm.*.font: ${normalFont cfg.fontSize},${backupFont cfg.fontSize}
!XTerm.*.boldFont: ${boldFont cfg.fontSize},${backupFont cfg.fontSize}
!XTerm.*.italicFont: ${italicFont cfg.fontSize},${backupFont cfg.fontSize}
!XTerm.*.bolditalicFont: ${itallicBoldFont cfg.fontSize},${backupFont cfg.fontSize}
XTerm.*.font: ${normalFont cfg.fontSize}
XTerm.*.boldFont: ${boldFont cfg.fontSize}
XTerm.*.italicFont: ${italicFont cfg.fontSize}
XTerm.*.bolditalicFont: ${itallicBoldFont cfg.fontSize}
'';
"X11/Xresource.d/xterm-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-xterm-colors" ''
!! Color Configuration
!! -------------------
!! 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}
XTerm*background: S_base03
XTerm*foreground: S_base0
XTerm*fading: 40
XTerm*fadeColor: S_base03
XTerm*cursorColor: S_base1
XTerm*pointerColorBackground: S_base01
XTerm*pointerColorForeground: S_base1
XTerm*color0: S_base02
XTerm*color1: S_red
XTerm*color2: S_green
XTerm*color3: S_yellow
XTerm*color4: S_blue
XTerm*color5: S_magenta
XTerm*color6: S_cyan
XTerm*color7: S_base2
XTerm*color9: S_orange
XTerm*color8: S_base03
XTerm*color10: S_base01
XTerm*color11: S_base00
XTerm*color12: S_base0
XTerm*color13: S_violet
XTerm*color14: S_base1
XTerm*color15: S_base3
'';
};
};
}