Code Runner Sound Effects
Play one random sound from the bundled audio collection when Code Runner executes code.
Included audio
The sounds/ folder contains the WAV files supplied in the user's Sounds.zip archive. Add more .wav, .mp3, or .ogg files to this folder before packaging.
Important integration detail
VS Code does not expose a supported API that lets one extension intercept another extension's toolbar-button click. This extension therefore provides two integration paths:
- Native Code Runner Run Code button (terminal mode): set Code Runner's
code-runner.runInTerminal setting to true, keep its terminal name as Code, and ensure VS Code shell integration is active. The extension listens for terminal shell execution events from that terminal and plays one sound per event. Set codeRunnerSoundEffects.codeRunnerTerminalName if your Code Runner terminal has a different name.
- Guaranteed command path: run Code Runner Sound Effects: Run Code with Sound from the Command Palette. It invokes Code Runner's own
code-runner.run command and plays one sound after the command is invoked. You can assign this command a keyboard shortcut or add it to an editor toolbar through a custom menu contribution.
If Code Runner is configured to use its Output channel (code-runner.runInTerminal: false), its toolbar run is not observable through a public execution event. Use the dedicated command path in that mode. The extension deliberately does not replace or monkey-patch Code Runner's command handler.
Requirements
- Visual Studio Code 1.93.0 or newer
- Code Runner
- Node.js and npm for building
- Audio player:
- Windows: PowerShell / .NET
System.Media.SoundPlayer (WAV)
- macOS:
afplay
- Linux: one of
paplay, aplay, or ffplay
Settings
| Setting |
Default |
Description |
codeRunnerSoundEffects.enabled |
true |
Enable/disable sound effects |
codeRunnerSoundEffects.codeRunnerTerminalName |
Code |
Terminal name used by Code Runner |
codeRunnerSoundEffects.soundsDirectory |
sounds |
Audio folder, relative to extension root or absolute |
codeRunnerSoundEffects.volume |
1 |
Reserved for future per-player volume support |
The audio player APIs used here do not expose a consistent cross-platform volume interface, so volume is metadata for a future implementation and is not currently applied.
Local development
npm install
npm run compile
- Open this folder in VS Code.
- Press
F5 to launch an Extension Development Host.
- Install/enable Code Runner in the development host.
- For native Run Code integration, set:
{
"code-runner.runInTerminal": true,
"codeRunnerSoundEffects.enabled": true,
"codeRunnerSoundEffects.codeRunnerTerminalName": "Code"
}
- Run a supported file using Code Runner's Run Code button.
- Alternatively, use the extension's own editor-title Run button, or run
Code Runner Sound Effects: Play Test Sound / Code Runner Sound Effects: Run Code with Sound from the Command Palette.
- Use Developer: Show Running Extensions and the Extension Host debug console to inspect activation and errors.
For Linux, install one supported audio backend if needed, e.g. sudo apt install pulseaudio-utils for paplay, sudo apt install alsa-utils for aplay, or sudo apt install ffmpeg for ffplay.
How random selection works
The extension selects uniformly from the bundled audio files. It persists the last selected path in VS Code global state and excludes that file from the next selection whenever at least two sounds exist. With only one file, that file is necessarily repeated.
Each terminal execution event triggers one call to the random player. The explicit wrapper suppresses its matching terminal event for five seconds and plays once itself.
Project files
package.json — Marketplace metadata, commands, settings, dependencies, scripts.
src/extension.ts — Extension activation, Code Runner integration, random selection, playback.
sounds/ — Bundled user-provided audio.
media/icon.png — Marketplace icon.
tsconfig.json — TypeScript compiler settings.\n- .vscode/launch.json and .vscode/tasks.json — local F5 debugging/build tasks.
.vscodeignore — Excludes development-only files from VSIX.
.gitignore — Excludes generated files and dependencies from Git.
LICENSE — MIT license.
Edit package.json:
name: permanent technical package name; use lowercase kebab-case.
displayName: friendly name shown in the Marketplace.
description: short Marketplace summary.
publisher: your exact Marketplace publisher ID (not your display name).
version: semantic version MAJOR.MINOR.PATCH; increment before every Marketplace release.
icon: path to a square PNG icon, preferably 128×128 or larger.
license, repository, homepage, bugs, keywords, categories: package and discovery metadata.
Replace media/icon.png with your own square PNG and keep the icon path correct. Avoid changing name after publishing because it is part of the extension identifier (publisher.name).
Package a VSIX
Install the official VS Code packaging CLI:
npm install --global @vscode/vsce
npm install
npm run compile
vsce package
This creates code-runner-sound-effects-1.0.0.vsix in the project directory. Review the package output and test the VSIX in a clean VS Code profile:
code --install-extension code-runner-sound-effects-1.0.0.vsix
Publish to the Visual Studio Code Marketplace
- Sign in to the Visual Studio Marketplace publisher management portal using the Microsoft account that will own the publisher.
- Create a publisher and choose a unique publisher ID. The publisher ID is the value required by
package.json's publisher field.
- Preferred: configure Trusted Publishing (GitHub Actions). In the publisher management portal, open your publisher's Trusted Publishing settings and create a policy for your exact GitHub repository and workflow file. In the workflow, grant
id-token: write and publish with npx @vscode/vsce publish --oidc. This avoids storing a long-lived publishing secret.
- If using a manual/legacy PAT workflow, create a token with the Marketplace Manage scope and authenticate with
vsce login YOUR_PUBLISHER_ID. Keep the token secret and never commit it. Note that global Azure DevOps PATs are scheduled for retirement on December 1, 2026; prefer federated publishing.
- Update
publisher, verify the metadata/icon/readme/license, and bump version.
- Build and package:
npm run compile
vsce package
Upload the generated .vsix through the publisher portal, or publish using your configured supported authentication method.
- For later releases, bump the version and repeat the build/package/publish steps.
Marketplace publication is not performed automatically by this project; it requires your publisher identity and Marketplace authorization. See the current official publishing guide before choosing an authentication method.
License
MIT. Confirm you have rights to redistribute every bundled sound before publishing the extension.
Sound Credit: https://youtu.be/8hN8cVe3hzU?si=rg4nGHp9WPFSUqA4