Skip to content

Commit

Permalink
just: Add option to disable Bluetooth headset profile
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar committed Oct 8, 2024
1 parent 233e9bb commit f2ae29b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ Installed flatpaks:
- [Extension Manager](https://flathub.org/apps/com.mattjakeman.ExtensionManager)
- [Easy Effects](https://flathub.org/apps/com.github.wwmm.easyeffects)

Optional config:
Optional just config:
- [Hide close button from windows](https://github.com/fiftydinar/gidro-os/wiki/6.-Gidro%E2%80%90OS-Config#how-to-apply-hide-close-button-from-windows-config) (useful for mouses which have a special key for closing applications window)
- [Scheduled nightly reboot](https://github.com/fiftydinar/gidro-os/wiki/6.-Gidro%E2%80%90OS-Config#how-to-apply-scheduled-nightly-reboot-config) (useful for applying system updates if you're leaving your PC turned on 24/7)
- [Management of official Android platform-tools](https://github.com/fiftydinar/gidro-os/wiki/6.-Gidro%E2%80%90OS-Config#how-to-manage-android-platform-tools) (useful for easy installing, updating & removing of Android platform-tools pulled from official Google source. `android-tools` official package is broken, so relying on this solution is better + it pairs nicely with existing Android udev rules)
- [Disable Bluetooth headset profile (HSP/HFP)](https://github.com/fiftydinar/gidro-os/wiki/6.-Gidro%E2%80%90OS-Config#how-to-disable-bluetooth-headset-profile) (useful if you don't use mic from Bluetooth headphones, so you don't get surprisingly switched to lower audio quality headset profile)

Settings applied by default:
- [Enabled experimental support for Variable Refresh Rate on supported screens](https://global.samsungdisplay.com/31137) (improves video & gaming experience by dynamically matching screen refresh rate with the content framerate)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## In WirePlumber there's a bug where some applications trigger switching to Headset Profile
## --
## See issue #634, #645, #630, #629, #613
## --
## This config mitigates the issue by completely disabling the switching and support for Headset Profile (HFP)
## Using this would only make sense if you never plan on using the microphone that comes with your headset.

wireplumber.settings = {
## Whether to use headset profile in the presence of an input stream.
## --
## Disable for now, as it causes issues. See note at the top as to why.
bluetooth.autoswitch-to-headset-profile = false
}

monitor.bluez.properties = {
## Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ])
##
## Currently some headsets (Sony WH-1000XM3) are not working with
## both hsp_ag and hfp_ag enabled, so by default we enable only HFP.
##
## Supported roles: hsp_hs (HSP Headset),
## hsp_ag (HSP Audio Gateway),
## hfp_hf (HFP Hands-Free),
## hfp_ag (HFP Audio Gateway)
## a2dp_sink (A2DP Audio Sink)
## a2dp_source (A2DP Audio Source)
## bap_sink (LE Audio Basic Audio Profile Sink)
## bap_source (LE Audio Basic Audio Profile Source)
## --
## Only enable A2DP here and disable HFP. See note at the top as to why.
bluez5.roles = [ a2dp_sink a2dp_source ]
}
41 changes: 41 additions & 0 deletions files/justfiles/gidro-os.just
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,44 @@ android-tools ACTION="prompt":
echo "Android platform-tools is uninstalled"
fi
fi
# Configure window close button
configure-bluetooth-headset-profile ACTION="prompt":
#!/usr/bin/env bash
source /usr/lib/ujust/ujust.sh
CURRENT_STATE="Enabled"
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
CURRENT_STATE="Disabled"
fi
OPTION={{ ACTION }}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring Bluetooth headset profile behavior${normal}"
echo "Bluetooth headset profile is currently: ${bold}${CURRENT_STATE}${normal}"
echo 'Disabling Bluetooth headset profile can be useful if you do not use mic from Bluetooth headphones & want to avoid lower audio quality from sudden headset profile switch.'
echo 'Enable or Disable Bluetooth headset profile? Press ESC to exit.'
OPTION=$(ugum choose "Enable (Default)" Disable)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-bluetooth-headset-profile <option>"
echo " <option>: Specify the quick option - 'disable' or 'enable'"
echo " Use 'disable' to disable Bluetooth headset profile."
echo " Use 'enable' to revert to defaults."
exit 0
fi
if [ "${OPTION,,}" == "disable" ]; then
if ! [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
mkdir -p "/etc/wireplumber/wireplumber.conf.d/"
cp "/usr/share/bluebuild/gidro-os/51-disable-bluetooth-headphone-profile-switch.conf" "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf"
systemctl --user restart wireplumber
echo 'Disable Bluetooth headset profile setting applied.'
else
printf "\e[1;31mERROR: Bluetooth headset profile is already disabled, no change is made.\e[0m\n" 1>&2
fi
elif [ "$OPTION" == "Enable (Default)" ] || [ "${OPTION,,}" == "enable" ]; then
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
rm "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf"
systemctl --user restart wireplumber
echo 'Reverted setting "Bluetooth headset profile" to defaults.'
else
printf "\e[1;31mERROR: Bluetooth headset profile is already enabled, no change is made.\e[0m\n" 1>&2
fi
fi

0 comments on commit f2ae29b

Please sign in to comment.