diff --git a/README.md b/README.md index bbc0d2c..8e9792d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Additionally I install next software, that is not (yet) presented in Brew: 1. Install Brew from here: https://brew.sh/ 2. Copy Brewfile to your computer and run `brew bundle` from the same folder where you copied the file. +3. Run `chmod +x ./cron-adjust-microphone-gain-to-100.sh` and `./cron-adjust-microphone-gain-to-100.sh` [to change microphone gain to 100% on macOS](https://apple.stackexchange.com/questions/97810/mac-osx-microphone-input-volume-level-auto-adjusts-can-it-be-disabled). Note: Brew will ask you for the root password and other apps inside Brewfile might ask you for your password as well. Usually installation takes 10-20 min, so make sure to brew a cup of tea or coffee :) diff --git a/cron-adjust-microphone-gain-to-100.sh b/cron-adjust-microphone-gain-to-100.sh new file mode 100755 index 0000000..133f0a4 --- /dev/null +++ b/cron-adjust-microphone-gain-to-100.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# If the microphone gain is less than 100, increase it by 3 every 0.1 seconds until it reaches 100 +CRON_JOB="* * * * * while (( \$(osascript -e \"input volume of (get volume settings)\") < 100 )); do osascript -e \"set volume input volume (input volume of (get volume settings) + 3)\"; sleep 0.1; done;" + +# Escape percent signs for cron +ESCAPED_CRON_JOB=$(echo "${CRON_JOB}" | sed 's/%/\\%/g') + +# Backup current crontab (just in case) +CRONTAB_BACKUP=$(crontab -l) + +# Check if the cron job already exists +if echo "${CRONTAB_BACKUP}" | grep -F -- "${CRON_JOB}" > /dev/null 2>&1; then + echo "Cron job already exists. Not adding again." +else + # Add the cron job to the crontab + (echo "${CRONTAB_BACKUP}"; echo "${ESCAPED_CRON_JOB}") | crontab - + echo "Cron job added." +fi