cava: add module

This commit is contained in:
Luna Simons 2023-06-16 21:38:29 +02:00 committed by Robert Helgesson
parent f540f30f1f
commit 6045b68ee7
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
7 changed files with 102 additions and 0 deletions

View File

@ -1281,6 +1281,13 @@ in
A new module is available: 'services.darkman'.
'';
}
{
time = "2023-10-24T06:14:53+00:00";
message = ''
A new module is available: 'programs.cava'.
'';
}
];
};
}

View File

@ -70,6 +70,7 @@ let
./programs/browserpass.nix
./programs/btop.nix
./programs/carapace.nix
./programs/cava.nix
./programs/chromium.nix
./programs/command-not-found/command-not-found.nix
./programs/comodoro.nix

52
modules/programs/cava.nix Normal file
View File

@ -0,0 +1,52 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.programs.cava;
iniFmt = pkgs.formats.ini { };
in {
meta.maintainers = [ maintainers.bddvlpr ];
options.programs.cava = {
enable = mkEnableOption "Cava audio visualizer";
package = mkPackageOption pkgs "cava" { };
settings = mkOption {
type = iniFmt.type;
default = { };
example = literalExpression ''
{
general.framerate = 60;
input.method = "alsa";
smoothing.noise_reduction = 88;
color = {
background = "'#000000'";
foreground = "'#FFFFFF'";
};
}
'';
description = ''
Settings to be written to the Cava configuration file. See
<https://github.com/karlstav/cava/blob/master/example_files/config> for
all available options.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."cava/config" = mkIf (cfg.settings != { }) {
text = ''
; Generated by Home Manager
${generators.toINI { } cfg.settings}
'';
};
};
}

View File

@ -70,6 +70,7 @@ import nmt {
./modules/programs/browserpass
./modules/programs/btop
./modules/programs/carapace
./modules/programs/cava
./modules/programs/comodoro
./modules/programs/darcs
./modules/programs/dircolors

View File

@ -0,0 +1,15 @@
; Generated by Home Manager
[color]
background='#000000'
foreground='#ffffff'
[general]
framerate=30
[input]
source=alsa
[smoothing]
noise_reduction=65

View File

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
programs.cava = {
enable = true;
package = config.lib.test.mkStubPackage { };
settings = {
general.framerate = 30;
input.source = "alsa";
smoothing.noise_reduction = 65;
color = {
background = "'#000000'";
foreground = "'#ffffff'";
};
};
};
nmt.script = ''
configFile=home-files/.config/cava/config
assertFileExists $configFile
assertFileContent $configFile ${./cava-basic-configuration-expected.ini}
'';
}

View File

@ -0,0 +1 @@
{ cava-basic-configuration = ./cava-basic-configuration.nix; }