Created
August 11, 2022 16:08
-
-
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`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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