From 3ee15dc5a6f5a2952845c2563a88c0e7dd7958b0 Mon Sep 17 00:00:00 2001 From: bricked Date: Sun, 22 Dec 2024 17:09:05 +0100 Subject: [PATCH] cava: add rainbow theme option (#638) Link: https://github.com/danth/stylix/pull/638 Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com> (cherry picked from commit be3a33d58999e92b98152aedcc59238f1c299f87) --- modules/cava/hm.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/cava/hm.nix diff --git a/modules/cava/hm.nix b/modules/cava/hm.nix new file mode 100644 index 000000000..fd88b7225 --- /dev/null +++ b/modules/cava/hm.nix @@ -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 + ); + }; +}