Skip to content

Commit

Permalink
cava: add rainbow theme option (#638)
Browse files Browse the repository at this point in the history
Link: #638

Co-authored-by: NAHO <[email protected]>
Tested-by: NAHO <[email protected]>
(cherry picked from commit be3a33d)
  • Loading branch information
brckd authored and trueNAHO committed Jan 4, 2025
1 parent 890582c commit 2879ff6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/cava/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ config, lib, ... }:

let

mkGradient = colors: lib.listToAttrs (lib.imap0 (i: c: lib.nameValuePair "gradient_color_${toString (i+1)}" "'#${c}'") colors) // {
gradient = 1;
gradient_count = builtins.length colors;
};

rainbowColors = with config.lib.stylix.colors; [
base0E
base0D
base0C
base0B
base0A
base09
base08
];

in {
options.stylix.targets.cava = {
enable = config.lib.stylix.mkEnableTarget "CAVA" true;
rainbow.enable = config.lib.stylix.mkEnableTarget "rainbow gradient theming" false;
};

config = let
cfg = config.stylix.targets.cava;
in
lib.mkIf (config.stylix.enable && cfg.enable) {
programs.cava.settings.color = lib.mkIf cfg.rainbow.enable (
mkGradient rainbowColors
);
};
}

0 comments on commit 2879ff6

Please sign in to comment.