Skip to content

A lightweight command-line tool for macOS that controls system audio volume. Features include resetting to default values (output 56%, input 50%), setting custom volume levels, and independent control of output/input audio. Built with Swift using Core Audio API and AppleScript.audio. Built with Swift using Core Audio API and AppleScript.

Notifications You must be signed in to change notification settings

weehong/macos-volume-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

macOS Volume Controller

A command-line tool for controlling system audio volume on macOS, written in Swift.

Features

  • Reset volumes to default values (output: 56%, input: 50%)
  • Set custom volume levels for both output and input
  • Control output or input volume independently
  • Works without requiring sudo or special permissions

Installation

  1. Clone or download this repository
  2. Compile the tool:
    make

Usage

Reset to Default Volumes

Reset output volume to 56% and input volume to 50%:

./volume_controller reset

Set Custom Volumes

Set both output and input volumes:

./volume_controller set <output> <input>

# Example: Set output to 70% and input to 60%
./volume_controller set 70 60

Control Output Volume Only

./volume_controller output <value>

# Example: Set output to 80%
./volume_controller output 80

Control Input Volume Only

./volume_controller input <value>

# Example: Set input to 40%
./volume_controller input 40

Show Help

./volume_controller help

Technical Details

  • Output Volume: Uses Core Audio API for precise control
  • Input Volume: Uses AppleScript for reliable control across macOS versions
  • Input Volume Rounding: macOS rounds input volume to specific increments (e.g., 50% may become 53%)

Files

  • volume_controller.swift - Main source code
  • volume_controller - Compiled executable
  • set_input_volume.swift - Original input-only version
  • Makefile - Build configuration

Requirements

  • macOS
  • Swift compiler (comes with Xcode or Command Line Tools)

Building from Source

# Using make
make

# Or compile directly
swiftc volume_controller.swift -o volume_controller

# Clean build files
make clean

License

This project is provided as-is for personal use.

About

A lightweight command-line tool for macOS that controls system audio volume. Features include resetting to default values (output 56%, input 50%), setting custom volume levels, and independent control of output/input audio. Built with Swift using Core Audio API and AppleScript.audio. Built with Swift using Core Audio API and AppleScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published