Skip to content

Instantly share code, notes, and snippets.

@dwreeves
Created August 11, 2022 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwreeves/5a1b723217ea63c4da5e703c8c943f44 to your computer and use it in GitHub Desktop.
Save dwreeves/5a1b723217ea63c4da5e703c8c943f44 to your computer and use it in GitHub Desktop.
OSX Monterey fix for auto-adjusting volumes with Bluetooth microphones. Add me to your `~/.local/bin` and `chmod +x ~/.local/bin`
#!/bin/bash
set -eo pipefail
function maybe_make_a_volume_adjustment {
volume=`osascript -e "input volume of (get volume settings)"`;
(( vol_adj=((volume+50)/2-volume)/5 ));
if [ ${vol_adj} -lt 0 ]
then
sign="-"
else
sign="+"
fi
if [ ${vol_adj} -ne 0 ]
then
echo Adjusting volume by ${vol_adj}
fi
osascript -e "set volume input volume (input volume of (get volume settings) ${sign} ${vol_adj#-})";
}
function continuously_control_the_volume {
while true ; do
maybe_make_a_volume_adjustment &
sleep 0.05;
done;
}
continuously_control_the_volume
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment