{ config, lib, pkgs, ... }: let cfg = config.os.core.audio; toggleMuteNotify = pkgs.writeShellScriptBin "toggle-mute-notify" '' IS_MUTED=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep -c "MUTED") if [ "$IS_MUTED" -eq 1 ]; then ${pkgs.libnotify}/bin/notify-send -a "MuteIndicator" -t 0 -u critical "Microphone Muted" "Mic is currently OFF" else ${pkgs.mako}/bin/makoctl dismiss -a "MuteIndicator" fi ''; in { options.os.core.audio = { enable = lib.mkEnableOption "audio support"; disable-devices.enable = lib.mkEnableOption "disables some random devices cluttering up"; }; config = lib.mkMerge [ (lib.mkIf cfg.enable { services = { pipewire = { enable = true; audio.enable = true; pulse.enable = true; alsa.enable = true; alsa.support32Bit = true; jack.enable = true; wireplumber.enable = true; }; playerctld.enable = true; spotifyd.enable = true; }; security.rtkit.enable = true; environment.systemPackages = with pkgs; [ toggleMuteNotify crosspipe alsa-utils ]; }) (lib.mkIf cfg.disable-devices.enable { services.pipewire.wireplumber.extraConfig = { "99-disable-useless-devices"."monitor.alsa.rules" = [ { matches = [ { "device.name" = "~alsa_card.pci-0000_03_00.1*"; } { "device.description" = "~USB Audio*"; } ]; actions.update-props = { "device.disabled" = true; }; } ]; }; }) ]; }