A Windows system tray application that monitors audio devices and provides quick switching capabilities with automatic preferred device selection.
- Runs quietly in the Windows system tray
- Custom icon with real-time device status
- Clean, organized menu interface
- Real-time Monitoring - Automatically detects when the active audio device changes
- Quick Device Switching - Switch between audio devices with a single click from the system tray
- Device List View - See all available audio output devices at a glance with visual indicators for the active device
- Toast Notifications - Receive Windows notifications when the audio device changes
- Auto-Select on Startup - Set a preferred default device that will be automatically selected when the application starts
- Persistent Configuration - Your preferred device choice is saved to disk and persists across restarts
- Easy Configuration - Set your preferred device through the system tray menu
- Lightweight background monitoring with minimal CPU usage
- Thread-safe COM operations with mutex synchronization
- Proper error handling for COM interface initialization
- Embedded application icons (no external dependencies)
- Windows OS
- Go 1.25.3 or higher
- Download the latest
audio-monitor-windows-amd64.zipfrom the Releases page - Extract the zip file to a location of your choice (e.g.,
C:\Program Files\AudioMonitor\) - Run
audio-monitor.exe
Note: No administrator privileges required.
To run the application automatically when you log in to Windows, use this PowerShell command:
# Run this in PowerShell (no admin required)
$exePath = "C:\Path\To\audio-monitor.exe" # Update this path
$action = New-ScheduledTaskAction -Execute $exePath
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 0
Register-ScheduledTask -TaskName "AudioDeviceMonitor" -Action $action -Trigger $trigger -Settings $settings -Description "Monitors audio device changes"To remove the auto-start task:
Unregister-ScheduledTask -TaskName "AudioDeviceMonitor" -Confirm:$false- Clone the repository:
git clone https://github.com/theonlyway/AudioDeviceMonitor.git
cd AudioDeviceMonitor- Install dependencies:
go mod tidy- Build the application:
go build -o bin/audio-monitor.exe ./cmd/audio-monitor- (Optional) Build without console window:
go build -ldflags -H=windowsgui -o bin/audio-monitor.exe ./cmd/audio-monitorRun the application:
.\audio-monitor.exeThe application will minimize to the system tray. Look for the icon in your system tray (near the clock).
The application adds an icon to your system tray with the following options:
-
Devices (submenu)
- Lists all available audio output devices
- Active device marked with ●
- Click any device to switch to it immediately
-
Set Preferred Default (submenu)
- Lists all available audio output devices
- Current preferred device marked with ✓
- Click any device to set it as your preferred default
- Automatically applied on next startup (if auto-switch is enabled)
-
Auto-Switch on Startup - Toggle automatic switching to preferred device on application startup
- When enabled (✓): Automatically switches to your preferred device when the app starts
- When disabled: Keeps current default device on startup
-
Quit - Exit the application
The application stores configuration and logs in:
%USERPROFILE%\.audio-monitor\
Configuration file (config.json):
- Automatically created when you set a preferred device
- Contains preferred device ID and name
- Persists across application restarts
Log file (audio-monitor.log):
- Contains application startup, device changes, and error messages
- Useful for troubleshooting issues
- Rotates automatically to prevent excessive disk usage
AudioDeviceMonitor/
├── assets/ # Static assets (icons)
│ ├── assets.go # Embedded assets
│ ├── systray_icon.png # System tray icon (recommended: 16x16 or 32x32 pixels)
│ └── toast_icon.png # Toast notification icon (recommended: 48x48 to 256x256 pixels)
├── bin/ # Build output (gitignored)
│ └── audio-monitor.exe
├── cmd/
│ └── audio-monitor/ # Application entrypoint
│ └── main.go
├── internal/
│ ├── audio/ # Audio device monitoring and control
│ │ └── monitor.go
│ ├── config/ # Configuration management
│ │ └── config.go
│ ├── notification/ # Toast notifications
│ │ └── toast.go
│ ├── tray/ # System tray interface
│ │ └── tray.go
│ └── windows/ # Windows COM interfaces
│ └── com.go
├── .gitignore
├── go.mod
├── go.sum
└── README.md
- Recommended size: 16x16 or 32x32 pixels
- Format: PNG with transparency
- Notes: The application converts PNG to ICO format at runtime
- High DPI: 32x32 provides better quality on high-DPI displays
- Recommended size: 48x48 to 256x256 pixels
- Format: PNG with transparency
- Notes: Windows automatically scales the icon; larger source images provide better quality
- Best practice: Use 256x256 for optimal display across all scenarios
github.com/go-ole/go-ole- Windows COM/OLE automationgithub.com/go-toast/toast- Windows toast notificationsgithub.com/getlantern/systray- System tray integrationgithub.com/tc-hib/winres- ICO conversion for system tray icons
The application uses the Windows Multimedia Device (MMDevice) API through COM to:
- Enumerate audio devices
- Get the default audio endpoint
- Retrieve device properties (ID and friendly name)
- Poll for changes at regular intervals
- Display toast notifications when changes are detected
The application uses official Microsoft-defined GUIDs from the Windows SDK to access COM interfaces:
- CLSID_MMDeviceEnumerator - COM class ID to create the device enumerator
- IID_IMMDeviceEnumerator - Interface for enumerating audio devices
- IID_IMMDevice - Interface for individual audio device operations
- IID_IPropertyStore - Interface for accessing device properties
- PKEY_Device_FriendlyName - Property key for retrieving the device's display name
These GUIDs are defined in Windows SDK headers (mmdeviceapi.h, functiondiscoverykeys_devpkey.h) and are consistent across all Windows systems.