Skip to content

Instantly share code, notes, and snippets.

@PoisonousJohn
Last active December 16, 2020 10:28
Show Gist options
  • Save PoisonousJohn/ca3875914fec6f767b7a951ebf3f9756 to your computer and use it in GitHub Desktop.
Save PoisonousJohn/ca3875914fec6f767b7a951ebf3f9756 to your computer and use it in GitHub Desktop.
Headset switcher service. Detects when Zoom is running and switches headset profile for the call, then switches it back, when the meeting is ended
[Unit]
Description=Music Player Daemon
[Service]
ExecStart=/home/jp/.config/systemd/user/headset-switcher.sh
[Install]
WantedBy=default.target
#!/bin/bash
while :
do
IS_HEADSET_AVAILABLE=`pactl list cards | grep bluez || echo -n ""`
IS_ZOOM_RUNNING=`pactl list source-outputs | grep ZOOM || echo -n ""`
if [ ! -z "$IS_HEADSET_AVAILABLE" -a "$IS_HEADSET_AVAILABLE" != " " ]; then
if [ ! -z "$IS_ZOOM_RUNNING" -a "$IS_ZOOM_RUNNING" != " " ]; then
pactl set-card-profile bluez_card.38_18_4C_0E_9E_C2 headset_head_unit
else
pactl set-card-profile bluez_card.38_18_4C_0E_9E_C2 a2dp_sink
fi
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment