diff --git a/modules/hardware/sound.nix b/modules/hardware/sound.nix index 8ef66a7..4efca20 100644 --- a/modules/hardware/sound.nix +++ b/modules/hardware/sound.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let cfg = config.hive.sound; @@ -17,6 +18,11 @@ in { default = false; description = "Enable Noisetorch for noise cancellation."; }; + noisetorch-threshold = lib.mkOption { + type = lib.types.int; + default = -1; + description = "Set the noise cancellation threshold for Noisetorch."; + }; }; }; config = lib.mkIf cfg.enable { @@ -36,5 +42,17 @@ in { #media-session.enable = true; }; programs.noisetorch.enable = cfg.noisetorch; + systemd.user.services.noisetorch-autoload = lib.mkIf cfg.noisetorch { + description = "Automatically load Noisetorch on user login"; + after = ["pipewire.service"]; + requires = ["pipewire.service"]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.noisetorch}/bin/noisetorch -l -t ${toString cfg.noisetorch-threshold}"; + ExecStop = "${pkgs.noisetorch}/bin/noisetorch -u"; + RemainAfterExit = true; + }; + wantedBy = ["default.target"]; + }; }; }