Santoshkumar Patil
Contact: 9036664017
Email: santoshpatil7968@gmail.com
Error Sound Notifier
A VS Code extension that plays sound notifications when errors appear or are fixed in your code.
Features
- 🔊 Plays a sound when an error is detected in the active file
- ✅ Plays a success sound when all errors are fixed
- 🎯 Tracks error state per file to avoid repeated triggers
- 🚀 Works with any language that provides diagnostics in VS Code
How It Works
The extension listens for diagnostics changes using vscode.languages.onDidChangeDiagnostics and:
- Monitors only the active editor file
- Detects when errors appear (transition from no errors to errors)
- Detects when errors are fixed (transition from errors to no errors)
- Prevents duplicate sound triggers by tracking previous error state
Installation & Setup
Prerequisites
- Node.js (v18 or higher)
- VS Code (v1.75.0 or higher)
- npm or yarn
Step 1: Install Dependencies
cd error-sound-notifier
npm install
Step 2: Add Sound Files
Create a sounds folder in the extension root and add two MP3 files:
error-sound-notifier/
├── sounds/
│ ├── error.mp3
│ └── success.mp3
├── src/
├── package.json
└── ...
Where to get sound files:
- Create your own or download from free sound libraries like:
- Keep files short (1-2 seconds) for best experience
- Ensure files are in MP3 format
Step 3: Compile the Extension
npm run compile
This compiles TypeScript to JavaScript in the out folder.
Running the Extension
Method 1: Debug/Test in Extension Development Host
- Open the
error-sound-notifier folder in VS Code
- Press
F5 or go to Run > Start Debugging
- A new VS Code window will open with the extension loaded
- Open any file with errors (or create some errors) to test
- Fix the errors to hear the success sound
Method 2: Install Locally
Package the extension:
npm install -g @vscode/vsce
npm run package
This creates a .vsix file (e.g., error-sound-notifier-1.0.0.vsix)
Install the extension:
- Open VS Code
- Go to Extensions view (
Ctrl+Shift+X)
- Click the
... menu → Install from VSIX
- Select the generated
.vsix file
Reload VS Code to activate the extension
Usage
Once installed and running:
- Open any code file in VS Code
- Introduce an error (e.g., syntax error, type error)
- 🔊 The error sound will play
- Fix the error and save the file
- ✅ The success sound will play
Example Test Cases
JavaScript/TypeScript:
// Introduce error (missing semicolon or undefined variable)
let x = undefinedVariable
// Fix it
let x = 5;
Python:
# Introduce error (syntax)
def hello(
print("hello")
# Fix it
def hello():
print("hello")
Windows
The extension uses PowerShell's Media.SoundPlayer (built-in, no dependencies required)
macOS
Uses afplay command (built-in)
Linux
Tries these commands in order:
paplay (PulseAudio)
aplay (ALSA)
ffplay (FFmpeg)
Install if needed:
# Ubuntu/Debian
sudo apt-get install pulseaudio-utils alsa-utils
# Fedora
sudo dnf install alsa-utils pulseaudio-utils
Project Structure
error-sound-notifier/
├── src/
│ └── extension.ts # Main extension logic
├── sounds/
│ ├── error.mp3 # Sound for errors (add this)
│ └── success.mp3 # Sound for success (add this)
├── out/ # Compiled JavaScript (generated)
├── node_modules/ # Dependencies (generated)
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── .vscodeignore # Files to exclude from package
└── README.md # This file
Configuration
Customizing Publisher Name
Before publishing, update the publisher field in package.json:
{
"publisher": "your-username"
}
You can register as a publisher at Visual Studio Marketplace.
Customizing Sound Files
Replace sounds/error.mp3 and sounds/success.mp3 with your preferred sounds.
Development
Watch Mode
For active development with auto-compilation:
npm run watch
Debugging
- Set breakpoints in
src/extension.ts
- Press
F5 to start debugging
- Check the Debug Console for logs
Packaging for Distribution
Create VSIX Package
npm run package
This creates error-sound-notifier-1.0.0.vsix
Publish to VS Code Marketplace
- Create a publisher account at https://marketplace.visualstudio.com/manage
- Get a Personal Access Token from Azure DevOps
- Login to vsce:
vsce login your-publisher-name
- Publish:
vsce publish
Troubleshooting
Sounds Not Playing
Check sound files exist:
- Verify
sounds/error.mp3 and sounds/success.mp3 are present
- Check the VS Code Output panel → "Error Sound Notifier" for warnings
Check platform audio:
- Windows: Ensure system sounds work
- macOS: Test with
afplay /System/Library/Sounds/Ping.aiff
- Linux: Install audio players (see above)
Check extension is active:
- Open Command Palette (
Ctrl+Shift+P)
- Type "Developer: Show Running Extensions"
- Look for "Error Sound Notifier"
Sounds Playing Too Often
The extension tracks error state to prevent repeated triggers. If you're hearing repeated sounds:
- Ensure you're testing in the active editor only
- Check that errors are truly transitioning (not just refreshing)
Extension Not Activating
- Check
package.json has correct activationEvents
- Run
Developer: Reload Window from Command Palette
- Check for errors in Developer Tools (
Help > Toggle Developer Tools)
Technical Details
Key Features
- Uses
vscode.languages.onDidChangeDiagnostics API
- Tracks error state per document URI to detect transitions
- Only monitors the active editor to avoid noise
- Prevents overlapping sound playback
- Cross-platform sound playback support
Error Detection Logic
// State transitions:
No errors → Has errors = Play error sound
Has errors → No errors = Play success sound
Has errors → Has errors = No sound
No errors → No errors = No sound
License
MIT License - Feel free to modify and distribute
Contributing
Suggestions and improvements welcome!
Future Enhancements
- [ ] Configuration settings for custom sound paths
- [ ] Volume control
- [ ] Option to filter by error severity
- [ ] Different sounds for warnings vs errors
- [ ] Visual notifications alongside sounds