Skip to content

mbeckenbach/mac-mic-volume-locker

Repository files navigation

Mac Mic Volume Locker

Lock your macOS microphone input volume to a fixed level so apps such as Microsoft Teams or Zoom stop fighting you. This repo pairs a tiny Swift helper with a launchd-managed shell script to keep one specific input device at the volume you choose. The project is heavily inspired by, and extends, hbertsch/macos-microphone-input-volume-locker.

Features

  • LaunchAgent bootstrap script that installs and restarts the watcher with one command
  • Configurable target volume, device name, and reset interval via mac-mic.conf
  • Swift helper that talks to CoreAudio so the exact input device is updated every cycle
  • Works entirely at the user level—no admin rights or system file changes required

Requirements

  • macOS with the built-in swift command-line tool (ships with Xcode Command Line Tools)
  • Permission to load user LaunchAgents (~/Library/LaunchAgents)

Installation

  1. Clone this repository and change into the directory (replace the URL with your fork if needed):

    git clone https://github.com/your-username/mac-mic-volume-locker.git
    cd mac-mic-volume-locker
  2. Make sure the helper scripts are executable (only needed once):

    chmod +x register-daemon.sh unregister-daemon.sh mac-mic-control.sh
  3. (Optional) Copy the example configuration and adjust it to match your hardware:

    cp mac-mic.conf.example mac-mic.conf
    vi mac-mic.conf
  4. Register the LaunchAgent so the watcher runs immediately and on every login:

    ./register-daemon.sh

The script writes a user LaunchAgent plist to ~/Library/LaunchAgents/com.user.miclock.plist that points to the local mac-mic-control.sh.

Configuration

  • TARGET_VOLUME: Volume percent (0–100) that should be enforced. Default: 25.
  • TARGET_DEVICE_NAME: Exact input device name as shown in System Settings ▸ Sound ▸ Input. Default: Built-in Microphone.
  • RESET_INTERVAL_SECONDS: How often the script enforces the volume. Default: 3 seconds.

All settings can be overridden by creating mac-mic.conf (see mac-mic.conf.example). The control script sources this file on every run, so updating the config and reloading the LaunchAgent is enough to change behavior.

After updating mac-mic.conf, rerun ./register-daemon.sh or manually launchctl bootout/launchctl bootstrap the plist to pick up the new settings.

Verifying the Service

Check whether the LaunchAgent is loaded:

launchctl list | grep com.user.miclock

If you see the identifier (with a PID or exit code 0), the watcher is active. Logs from the script are written to ~/Library/Logs by launchd; you can also run tail -f ~/Library/Logs/com.user.miclock.log if you configured log redirection.

Uninstallation

./unregister-daemon.sh

The script unloads the LaunchAgent and removes ~/Library/LaunchAgents/com.user.miclock.plist. You can safely delete the repository folder afterwards.

Project Structure

.
├── mac-mic-control.sh         # Main loop that enforces the target input volume
├── mac-mic.conf.example       # Sample override configuration
├── mac-mic.conf               # (Optional) Local configuration, not committed
├── resources/
│   └── set_input_volume.swift # Swift helper that talks to CoreAudio
├── register-daemon.sh         # Installs/refreshes the LaunchAgent
├── unregister-daemon.sh       # Removes the LaunchAgent
└── com.user.miclock.plist     # LaunchAgent template consumed by the installer

Credits

  • Original idea and CC BY-NC 4.0 licensed implementation by hbertsch.
  • This fork adds per-device configuration and a Swift helper to keep volume changes resilient.

License

Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).

About

Locks the microphone volume for a specific audio input device on macos

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published