Add colorscheme generator function

This commit is contained in:
Agatha Lovelace 2023-03-26 18:04:50 +02:00
parent 9eda1cc1f6
commit 26c36c4cc5
Signed by: sorceress
GPG Key ID: 01D0B3AB10CED4F8
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
{ lib, pkgs, ... }: {
colorscheme = name: image: rec {
generate = pkgs.callPackage ({ runCommand, colorz }:
runCommand name { nativeBuildInputs = [ colorz ]; } ''
colorz ${image} --no-preview -n 8 --bold 30 --minv 0 --maxv 255 | awk '{print $1} {print $2}' > $out
'') { };
colors = builtins.listToAttrs (lib.lists.imap0 (i: v: {
name = builtins.toString i;
value = v;
}) (lib.strings.splitString "\n" (builtins.readFile generate)));
};
}