Created
May 31, 2018 17:10
-
-
Save rsalmond/52bc5dc22c218ceb42f4f5a7340ba231 to your computer and use it in GitHub Desktop.
Pin osx audio input level, prevent "smart" adjustment.
This file contains hidden or 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
#!/usr/bin/env bash | |
#Keep the gain pegged at the desired input level | |
poll=3 | |
vol=100 | |
help() { | |
cat <<EOF | |
Usage: | |
$0 [-h|--help] [-p|--polling=<polling rate>] [-v|--volume=<volume>] | |
-h, --help Show help | |
-p, --polling=polling_rate Specify the polling rate in seconds | |
-v, --volume=volume Specify the input volume (0 - 100) | |
EOF | |
} | |
grip() { | |
while true; do | |
osascript -e "set volume input volume $vol" | |
sleep $poll | |
done | |
} | |
while test $# -gt 0; do | |
case "$1" in | |
-h|--help) | |
help | |
exit 0 | |
;; | |
-p) | |
shift | |
if test $# -gt 0; then | |
poll=$1 | |
else | |
echo "polling rate not specified" | |
exit 1 | |
fi | |
shift | |
;; | |
--polling*) | |
poll=`echo $1 | sed -e 's/^[^=]*=//g'` | |
shift | |
;; | |
-v) | |
shift | |
if test $# -gt 0; then | |
vol=$1 | |
else | |
echo "volume not specified" | |
exit 1 | |
fi | |
shift | |
;; | |
--volume*) | |
vol=`echo $1 | sed -e 's/^[^=]*=//g'` | |
shift | |
;; | |
*) | |
echo "Unknown option: $1" | |
help | |
exit 1 | |
;; | |
esac | |
done | |
grip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment