funkytions/nightmare/getKittyColorscheme.nix

49 lines
1.3 KiB
Nix
Raw Permalink Normal View History

2024-01-12 14:11:32 +01:00
{ lib, config, pkgs, ... }:
arg:
with lib;
let cfg = config.colorscheme;
getKittyTheme = with builtins; (theme:
let matching = filter (x: x.name == theme)
(fromJSON
(readFile
"${pkgs.kitty-themes}/share/kitty-themes/themes.json"));
in throwIf (length matching == 0)
"kitty-themes does not contain a theme named ${theme}"
"${pkgs.kitty-themes}/share/kitty-themes/${(head matching).file}");
unwrapKittyTheme = with pkgs; path: let
theme = runCommand "theme.toml" { nativebuildinputs = [ coreutils ]; } ''
cat '${path}' | sed -E '/^#|^$/d;s/\s+(.*)/ = "\1"/g' > $out
'';
in (builtins.fromTOML (builtins.readFile theme));
2024-03-08 13:08:24 +01:00
defaultTheme = {
selection_foreground = "";
selection_background = "";
foreground = "";
background = "";
color0 = "";
color1 = "";
color2 = "";
color3 = "";
color4 = "";
color5 = "";
color6 = "";
color7 = "";
color8 = "";
color9 = "";
color10 = "";
color11 = "";
color12 = "";
color13 = "";
color14 = "";
color15 = "";
cursor = "";
cursor_text_color = "";
url_color = "";
};
in defaultTheme // unwrapKittyTheme (getKittyTheme arg)