Skip to content

Commit f2ae29b

Browse files
committed
just: Add option to disable Bluetooth headset profile
1 parent 233e9bb commit f2ae29b

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ Installed flatpaks:
9696
- [Extension Manager](https://flathub.org/apps/com.mattjakeman.ExtensionManager)
9797
- [Easy Effects](https://flathub.org/apps/com.github.wwmm.easyeffects)
9898

99-
Optional config:
99+
Optional just config:
100100
- [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)
101101
- [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)
102102
- [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)
103+
- [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)
103104

104105
Settings applied by default:
105106
- [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)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## In WirePlumber there's a bug where some applications trigger switching to Headset Profile
2+
## --
3+
## See issue #634, #645, #630, #629, #613
4+
## --
5+
## This config mitigates the issue by completely disabling the switching and support for Headset Profile (HFP)
6+
## Using this would only make sense if you never plan on using the microphone that comes with your headset.
7+
8+
wireplumber.settings = {
9+
## Whether to use headset profile in the presence of an input stream.
10+
## --
11+
## Disable for now, as it causes issues. See note at the top as to why.
12+
bluetooth.autoswitch-to-headset-profile = false
13+
}
14+
15+
monitor.bluez.properties = {
16+
## Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ])
17+
##
18+
## Currently some headsets (Sony WH-1000XM3) are not working with
19+
## both hsp_ag and hfp_ag enabled, so by default we enable only HFP.
20+
##
21+
## Supported roles: hsp_hs (HSP Headset),
22+
## hsp_ag (HSP Audio Gateway),
23+
## hfp_hf (HFP Hands-Free),
24+
## hfp_ag (HFP Audio Gateway)
25+
## a2dp_sink (A2DP Audio Sink)
26+
## a2dp_source (A2DP Audio Source)
27+
## bap_sink (LE Audio Basic Audio Profile Sink)
28+
## bap_source (LE Audio Basic Audio Profile Source)
29+
## --
30+
## Only enable A2DP here and disable HFP. See note at the top as to why.
31+
bluez5.roles = [ a2dp_sink a2dp_source ]
32+
}

files/justfiles/gidro-os.just

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,44 @@ android-tools ACTION="prompt":
275275
echo "Android platform-tools is uninstalled"
276276
fi
277277
fi
278+
279+
# Configure window close button
280+
configure-bluetooth-headset-profile ACTION="prompt":
281+
#!/usr/bin/env bash
282+
source /usr/lib/ujust/ujust.sh
283+
CURRENT_STATE="Enabled"
284+
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
285+
CURRENT_STATE="Disabled"
286+
fi
287+
OPTION={{ ACTION }}
288+
if [ "$OPTION" == "prompt" ]; then
289+
echo "${bold}Configuring Bluetooth headset profile behavior${normal}"
290+
echo "Bluetooth headset profile is currently: ${bold}${CURRENT_STATE}${normal}"
291+
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.'
292+
echo 'Enable or Disable Bluetooth headset profile? Press ESC to exit.'
293+
OPTION=$(ugum choose "Enable (Default)" Disable)
294+
elif [ "$OPTION" == "help" ]; then
295+
echo "Usage: ujust configure-bluetooth-headset-profile <option>"
296+
echo " <option>: Specify the quick option - 'disable' or 'enable'"
297+
echo " Use 'disable' to disable Bluetooth headset profile."
298+
echo " Use 'enable' to revert to defaults."
299+
exit 0
300+
fi
301+
if [ "${OPTION,,}" == "disable" ]; then
302+
if ! [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
303+
mkdir -p "/etc/wireplumber/wireplumber.conf.d/"
304+
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"
305+
systemctl --user restart wireplumber
306+
echo 'Disable Bluetooth headset profile setting applied.'
307+
else
308+
printf "\e[1;31mERROR: Bluetooth headset profile is already disabled, no change is made.\e[0m\n" 1>&2
309+
fi
310+
elif [ "$OPTION" == "Enable (Default)" ] || [ "${OPTION,,}" == "enable" ]; then
311+
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
312+
rm "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf"
313+
systemctl --user restart wireplumber
314+
echo 'Reverted setting "Bluetooth headset profile" to defaults.'
315+
else
316+
printf "\e[1;31mERROR: Bluetooth headset profile is already enabled, no change is made.\e[0m\n" 1>&2
317+
fi
318+
fi

0 commit comments

Comments
 (0)