{ pkgs, config, lib, ... }: with lib; let cfg = config.eboskma.sound; in { options.eboskma.sound.enable = mkEnableOption "activate sound settings"; config = mkIf (cfg.enable) { sound.enable = true; services = { pipewire = { enable = true; pulse.enable = true; media-session = { enable = false; config = { bluez-monitor.rules = [ { matches = [{"device.name" = "~bluez_card.*";}]; actions = { "update-props" = { "bluez5.reconnect-profiles" = ["hfp_hf" "hsp_hs" "a2dp_sink"]; "bluez5.msbc-support" = true; "bluez5.sbc-xq-support" = true; }; }; } { matches = [ {"node.name" = "~bluez_input.*";} {"node.name" = "~bluez_output.*";} ]; actions = { "node.pause-on-idle" = false; }; } ]; }; }; }; }; environment.etc = { bluez_monitor = { target = "wireplumber/bluetooth.lua.d/50-bluez-config.lua"; text = '' bluez_monitor.properties = { ["bluez5.enable-msbc"] = true, ["bluez5.enable-sbc-xq"] = true, ["bluez5.headset-roles"] = "[ hfp_hf hsp_hs hsp_ag hfp_ag ]", ["bluez5.codecs"] = "[ sbc sbc_xq aac ]", ["bluez5.hfphsp-backend"] = "native", ["bluez5.default.rate"] = 48000, ["bluez5.default.channels"] = 2, } ''; }; }; security.rtkit.enable = true; environment.systemPackages = with pkgs; [pavucontrol]; users.extraUsers.${config.eboskma.var.mainUser}.extraGroups = ["audio"]; }; }