Disabling Handsfree Audio on NixOS

Oct 25, 2024 • nixos

In this post I want to share my nix configuration that disables the handsfree audio profile of all output devices.

Disabling Handsfree Audio on NixOS
image source

For over two years, I couldn't figure out how to disable the handsfree profile of my headphones in a simple way, unlike on Windows in the sound settings. Now, with OBS and LedFX automatically defaulting to that profile for whatever reason, it became even a bigger issue to me.

If you're using PipeWire, you can fix this by adding the following section to your configuration.nix:

{
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    wireplumber = {
      enable = true;
      configPackages = [
        (pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/51-mitigate-annoying-profile-switch.conf" ''
          wireplumber.settings = {
            bluetooth.autoswitch-to-headset-profile = false
          }

          monitor.bluez.properties = {
            bluez5.roles = [ a2dp_sink a2dp_source ]
          }
        '')
      ];
    };
  };
}

If you want to know more about what it does, check out this ArchWiki post.

Then switch to the the new profile:

sudo nixos-rebuild switch

If the handsfree profile still shows up, just restart the PipeWire service with:

systemctl --user restart pipewire.service pipewire-pulse.service 

Now it should work. Enjoy :)