Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mss/73b6630a24d8fda23458af2aaddf890b to your computer and use it in GitHub Desktop.
Save mss/73b6630a24d8fda23458af2aaddf890b to your computer and use it in GitHub Desktop.
Make the Ubuntu Zoom client automatically switch Bluetooth headset profiles to HSP/HFP
#!/bin/bash
# This is a hack to make Bluetooth headests like the jabra Evolve 65 actually
# work as a headset with the Linux (Ubuntu/Debian) Zoom client without having
# to switch manually from A2DP to the HSP/HFP profile.
#
# This is done by injecting an environment variable which makes PulseAudio
# recognize the application as a telephony/voice application as described
# here:
# * https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#profiles
# * https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/ApplicationProperties/#pa_prop_media_role
#
# An alternative to this might be to adapt the desktop file instead as
# described here
# * https://gavv.github.io/articles/pulseaudio-under-the-hood/#autodetecting-properties
#
set -o errexit
set -o pipefail
test ! -f /opt/zoom/zoom.distrib
# Make sure sudo works and avoid password prompt for the following commands
sudo true
# Install the zoom wrapper script
sudo install -m 0755 /dev/stdin /opt/zoom/zoom.wrapper <<'EOD'
#!/bin/bash
ZOOM="$(dirname "$0")/zoom.distrib"
exec /usr/bin/env PULSE_PROP_media.role=phone "$BASH" -c 'exec -a "${0%.*}" "$0" "$@"' "$ZOOM" "$@"
EOD
# Move real zoom binary out if the way
sudo dpkg-divert --rename --add /opt/zoom/zoom
# Symlink zoom wrapper script in place
sudo ln -s zoom.wrapper /opt/zoom/zoom
@mss
Copy link
Author

mss commented Jul 28, 2021

I think these steps should roll the changes back:

sudo rm /opt/zoom/zoom /opt/zoom/zoom.wrapper
sudo dpkg-divert --rename --remove /opt/zoom/zoom

@shmu26
Copy link

shmu26 commented Jul 28, 2021

Thanks.
I get an error when running the script, maybe you can help me solve this

sh /home/shmuel/Downloads/73b6630a24d8fda23458af2aaddf890b-2c8d4e75fd78208ba57b474d21d73cbe06a24749/zoom-pulse-prop-media-role-phone-wrapper-installer.sh /home/shmuel/Downloads/73b6630a24d8fda23458af2aaddf890b-2c8d4e75fd78208ba57b474d21d73cbe06a24749/zoom-pulse-prop-media-role-phone-wrapper-installer.sh: 17: set: Illegal option -o pipefail

@mss
Copy link
Author

mss commented Jul 28, 2021

Try bash instead of sh.

@shmu26
Copy link

shmu26 commented Jul 28, 2021 via email

@mss
Copy link
Author

mss commented Jul 29, 2021

I ran the script successfully with bash. It forces the audio profile of my bose bluetooth headphones to off. I can manually switch to headset, but it won't switch to high fidelity even if I try to do it manually.

That's very interesting. Might be either an issue with your Bose headset or the PulseAudio version on your Kubuntu. I use this on KDE Neon (which is based on Ubuntu 20.04 bit IIRC has a backported newer PulseAudio package) with a Jabra Evolve 65. It works mostly fine though sometimes it goes into a hectic loop where it switches between the two profiles.

I hope the roll-back steps work for you.

@shmu26
Copy link

shmu26 commented Jul 29, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment