vscode: Audio bell does not work in integrated terminal

  • VSCode Version: 1.22.1 (commit 950b8b0d37a9b7061b6f0d291837ccc4015f5ecd)
  • OS Version: Ubuntu 17.10

Steps to Reproduce:

  1. Open an integrated terminal
  2. Type echo "\a"

Assuming your OS is configured to allow TTY, you should hear a bell. In a normal terminal, this works fine. In code’s, it does not.

Does this issue occur when all extensions are disabled?: Yes

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 23
  • Comments: 54 (24 by maintainers)

Commits related to this issue

Most upvoted comments

I think an audible bell would be preferable

@tjx666 it was never lacking shell integration, it’s an issue with Electron sound. We seem to have worked around those since audio cues are now supported, this just needs someone to investigate and create a sound (which I’ve requested internally).

we will release this version in a few weeks @nnWhisperer

Electron appears to offer a way to invoke the default system sound: shell.beep()

https://www.electronjs.org/docs/api/shell#shellbeep

it’s been a long road. getting from there to here. -rest of the enterprise theme song-

I know it’s not the sound, but a visual bell is coming in the upcoming release which is driven by the same setting: https://github.com/microsoft/vscode/issues/121939

image

here is a +1 from 2021

Commit: 92192baf760315ac47fb2caaf3ce6d0778962352
Date: 2020-12-03T05:43:59.635Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041```

MacOS work-around: osascript -e "beep beep beep"

I’m seeing this too.

Even with terminal.integrated.enableBell enabled, running printf "\a" in the VS Code Integrated Terminal triggers no sound, despite the same command triggering a sound in my OS terminal.

MacOS 10.14.5

Just wanted to add a data point about this commands usefulness:

I typically run commands that take 1-2 minutes to complete in the terminal. Ex: building or compiling a program In iTerm or terminal app, I tend to append the beep command at the end of my program to let me know when its done.

Personal reason:

  • I try to avoid getting distracted in this short 1-2 minute period, like checking twitter, so by having the beep command, I just close my eyes and let the beep command tell me when my command is done 🔔
npm run build && beep

Work around for now for VSCode terminal:

As other’s have mentioned there is a work around. I’ve created these shell aliases below that can be added to your .bashrc, .zshrc files etc.

alias beep="osascript -e 'beep'"  # ring 1 time

# Below are 2  examples of customizeable version of beep

alias beep='function donebeep(){ for i in {1..10}; do osascript -e beep; done };donebeep' # run 10 times
alias beep='function donebeep(){ for i in {1..$1}; do osascript -e beep; done };donebeep' # run N time

Usage:

# Let me know when my command is done...going to relax 😄
npm run build && beep 10

@tjx666 I think it will look bad if we change the title in the dropdown as other titles will shift around when the bell triggers. We might end up adding a visual bell mode later on when this issue gets tackled that will flash the border around the terminal or something.

I can also reproduce this issue in macOS with

echo -ne '\007'

VS Code: 1.34.0 macOS: 10.14.5

i can confirm printf '\a' or echo '\a' will give a chime. BUT:

it is NOT the system chime, NOR does it bump the VSCode icon in the dock, NOR does it add a notification icon to VSCode in the dock. (terminal does all this, see icon attached) image

to reproduce in terminal, you might have to test it using a sleep, so you have time to unfocus the terminal before it rings the bell:

sleep 5 && printf '\a' and then quickly focus another app within 5 seconds

Found myself on Version: 1.72.2 and can confirm that enabling the setting does in fact give you a bell sound 😄

Enable with Cmd + Shift + P, search/select Preferences: Open Settings (UI), search for “bell” and check on the “Terminal > Integrated: Enable Bell” toggle.

screenshot of settings

Can also use

"terminal.integrated.enableBell": true

Moving forward printf '\a' will give you a chime.

The audio bell works on my computer! Thanks for your work - this has been a huge pain point for my workflow for years.

You need to opt in w the setting for it to work (it’s off by default)

It’s nice that there are workarounds like osascript, but many existing shell scripts expect the actual bell (tput bel) to work and don’t allow any customization to replace it with anything else.

Same issue on : Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:30:02.420Z Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 18.7.0

Tested via nodejs with : console.log(“\x07”) workaround :

const ringSpeaker = () => {
    const { exec } = require("child_process");
    exec('osascript -e "beep beep beep"'); 
};

Wish it worked in a loop, so that function could accept nTimes argument for number of beeps.

Using speaker-test in vscode terminal (Arch Linux) also fails to emit audio. Outside vscode it is working fine.

speaker-test -t waw -c 6
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
Playback open error: -2,No such file or directory

@deepak1556 I just found a public domain bell-like sound. xterm.js is a web app and doesn’t have access to some system bell sound.