From 47e3d662c4f6e31b560693fe0c87681c039a592c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 15 May 2018 13:01:53 +0200 Subject: Balance --- custom/trivmix-service.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'custom/trivmix-service.nix') diff --git a/custom/trivmix-service.nix b/custom/trivmix-service.nix index 9ebf02f1..f2d549fe 100644 --- a/custom/trivmix-service.nix +++ b/custom/trivmix-service.nix @@ -39,6 +39,18 @@ let description = "Volumes of mixers that share a group name are synchronised"; }; + balance = mkOption { + type = types.nullOr types.str; + default = null; + description = "Volumes of mixers are multiplied with their balances, this is the name of the file that contains the factor for this mixer"; + }; + + initialBalance = mkOption { + type = types.str; + default = "1"; + description = "Initial balance"; + }; + initial = mkOption { type = types.str; default = "1"; @@ -60,8 +72,11 @@ let mixerDeps = filter (x: any (hasPrefix (x + ":")) connectIn || any (hasPrefix (x + ":")) connectOut) (attrNames cfg); - trivmixArgs = [ "--client" name "--level" initial ] + trivmixArgs = let + dirName = if isNull group then name else group; + in [ "--client" name "--level" initial "--initial-balance" initialBalance] ++ optionals connect ["--run" connectScript] + ++ optionals (adjustable && (! isNull balance)) ["--balance" "/dev/shm/mix/${dirName}/${balance}"] ++ optional (adjustable && isNull group) "/dev/shm/mix/${name}/level" ++ optional (! isNull group) "/dev/shm/mix/${group}/level"; in { -- cgit v1.2.3