From 6d46c769fd0f86fcd4b051acdb9bc7c65298a527 Mon Sep 17 00:00:00 2001
From: Nate Anderson <nate.anderson@vasion.com>
Date: Tue, 7 Jan 2025 13:20:27 -0700
Subject: [PATCH] Fix for bluetooth headphones, switch between headset and hifi

---
 nate-work/modules/hypr/hyprland.nix | 35 +++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/nate-work/modules/hypr/hyprland.nix b/nate-work/modules/hypr/hyprland.nix
index ba38966..97827c1 100644
--- a/nate-work/modules/hypr/hyprland.nix
+++ b/nate-work/modules/hypr/hyprland.nix
@@ -140,12 +140,18 @@ in
       alsa.support32Bit = true;
       pulse.enable = true;
       wireplumber.enable = true;
-      wireplumber.extraConfig.bluetoothEnhancements = {
-        "monitor.bluez.properties" = {
-            "bluez5.enable-sbc-xq" = true;
-            "bluez5.enable-msbc" = true;
-            "bluez5.enable-hw-volume" = true;
-            "bluez5.roles" = [ "hsp_hs" "hsp_ag" "hfp_hf" "hfp_ag" "a2dp_sink" "a2dp_source" ];
+      wireplumber.extraConfig = {
+        "wireplumber.settings" = {
+          bluetooth.autoswitch-to-headset-profile = false;
+        };
+        bluetoothEnhancements = {
+          "monitor.bluez.properties" = {
+              "bluez5.enable-sbc-xq" = true;
+              "bluez5.enable-msbc" = true;
+              "bluez5.enable-hw-volume" = true;
+              # Default roles: https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/bluetooth.html#monitor-properties
+              "bluez5.roles" = [ "a2dp_sink" "a2dp_source" "bap_sink" "bap_source" "hfp_hf" "hfp_ag" ];
+          };
         };
       };
     };
@@ -165,9 +171,20 @@ in
     systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
 
     services.usbmuxd.enable = true;
-    hardware.bluetooth.enable = true; # enables support for Bluetooth
-    hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
-
+    hardware.bluetooth = {
+      enable = true;
+      powerOnBoot = true; # powers up the default Bluetooth controller on boot
+      settings  = {
+        General = {
+          Name = "Nate-Vasion";
+          ControlleMode = "dual";
+          FastConnectable = "true";
+          Experimental = "true";
+        };
+        Policy = { AutoEnable = "true"; };
+        LE = { EnableAdvMonInterleaveScan = "true"; };
+      };
+    };
     #
     # Nvidia Setup
     #