From 0a9f7157fc5380c905e6314a85887da720bb3cfc Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Fri, 7 Jun 2024 13:36:29 +0100 Subject: [PATCH] Update alacritty config to generate theme dynamically --- .../desktop/alacritty/catppuccin-mocha.toml | 75 ---------------- programs/desktop/alacritty/default.nix | 90 ++++++++++++++----- 2 files changed, 66 insertions(+), 99 deletions(-) delete mode 100644 programs/desktop/alacritty/catppuccin-mocha.toml diff --git a/programs/desktop/alacritty/catppuccin-mocha.toml b/programs/desktop/alacritty/catppuccin-mocha.toml deleted file mode 100644 index 1dfe857..0000000 --- a/programs/desktop/alacritty/catppuccin-mocha.toml +++ /dev/null @@ -1,75 +0,0 @@ -[colors.primary] -background = "#1E1E2E" -foreground = "#CDD6F4" -dim_foreground = "#CDD6F4" -bright_foreground = "#CDD6F4" - -[colors.cursor] -text = "#1E1E2E" -cursor = "#F5E0DC" - -[colors.vi_mode_cursor] -text = "#1E1E2E" -cursor = "#B4BEFE" - -[colors.search.matches] -foreground = "#1E1E2E" -background = "#A6ADC8" - -[colors.search.focused_match] -foreground = "#1E1E2E" -background = "#A6E3A1" - -[colors.footer_bar] -foreground = "#1E1E2E" -background = "#A6ADC8" - -[colors.hints.start] -foreground = "#1E1E2E" -background = "#F9E2AF" - -[colors.hints.end] -foreground = "#1E1E2E" -background = "#A6ADC8" - -[colors.selection] -text = "#1E1E2E" -background = "#F5E0DC" - -[colors.normal] -black = "#45475A" -red = "#F38BA8" -green = "#A6E3A1" -yellow = "#F9E2AF" -blue = "#89B4FA" -magenta = "#F5C2E7" -cyan = "#94E2D5" -white = "#BAC2DE" - -[colors.bright] -black = "#585B70" -red = "#F38BA8" -green = "#A6E3A1" -yellow = "#F9E2AF" -blue = "#89B4FA" -magenta = "#F5C2E7" -cyan = "#94E2D5" -white = "#A6ADC8" - -[colors.dim] -black = "#45475A" -red = "#F38BA8" -green = "#A6E3A1" -yellow = "#F9E2AF" -blue = "#89B4FA" -magenta = "#F5C2E7" -cyan = "#94E2D5" -white = "#BAC2DE" - -[[colors.indexed_colors]] -index = 16 -color = "#FAB387" - -[[colors.indexed_colors]] -index = 17 -color = "#F5E0DC" diff --git a/programs/desktop/alacritty/default.nix b/programs/desktop/alacritty/default.nix index f387984..d56ef43 100644 --- a/programs/desktop/alacritty/default.nix +++ b/programs/desktop/alacritty/default.nix @@ -1,29 +1,71 @@ -{fonts, ...}: { - programs.alacritty = let - catppuccin-mocha = builtins.fromTOML (builtins.readFile ./catppuccin-mocha.toml); - in { +{ + config, + fonts, + ... +}: { + programs.alacritty = { enable = true; - settings = - { - font = { - size = fonts.sizes.applications; - normal = { - family = fonts.monospace.name; - style = "Regular"; - }; + settings = { + font = { + size = fonts.sizes.applications; + normal = { + family = fonts.monospace.name; + style = "Regular"; }; - window = { - dynamic_title = true; - padding = { - x = 10; - y = 10; - }; - decorations = "none"; + }; + window = { + dynamic_title = true; + padding = { + x = 10; + y = 10; }; - live_config_reload = false; - selection.save_to_clipboard = true; - mouse.hide_when_typing = false; - } - // catppuccin-mocha; + decorations = "none"; + opacity = 0.9; + }; + live_config_reload = true; + selection.save_to_clipboard = true; + mouse.hide_when_typing = true; + colors = let + mapColours = isBright: (builtins.listToAttrs (builtins.map (col: { + # Alacritty uses Yellow instead of Orange for BASE09 + name = + if col == "orange" + then "yellow" + else col; + value = "0x${config + .scheme + .${ + if isBright + then "bright-${col}" + else col + }}"; + }) + ["red" "orange" "green" "cyan" "blue" "magenta"])); + mapNamedColours = mapColours false; + mapNamedBrightColours = mapColours true; + in { + draw_bold_text_with_bright_colors = false; + primary = with config.scheme; { + background = "0x${base00}"; + foreground = "0x${base05}"; + }; + cursor = with config.scheme; { + cursor = "0x${base05}"; + text = "0x${base00}"; + }; + normal = with config.scheme; + { + black = "0x${base00-hex}"; + white = "0x${base05-hex}"; + } + // mapNamedColours; + bright = with config.scheme; + { + black = "0x${base03-hex}"; + white = "0x${base07-hex}"; + } + // mapNamedBrightColours; + }; + }; }; }