5

I was thinking , would it be helpful and efficient to get a notification(sound or popup) back after npm finish running a task , a long installation for example . I'm using vscode and running most of my command in the integrated terminal and while waiting for it to finish I ended up spending more time on doing other task that is non-productive.

nymhays
  • 468
  • 3
  • 12
  • 1
    Perhaps `npm install; [search on how to make a sound from bash]`, e.g. [this](https://stackoverflow.com/questions/1143386/in-a-bash-script-command-how-can-i-make-a-pc-beep-noise-or-play-a-sound-file) - `;` instead of `&&` since you may want an alert even if it fails. – Jeppe Jan 24 '20 at 08:30

5 Answers5

5

So we can break this down to running npm install, followed by some way of making a sound. According to this thread, a simple beep can be done using: echo -en "\007".

Combine these two, and you get: npm install; echo -en "\007"

The use of ; ensures that the beep is played even if npm install fails (as opposed to && which only runs the beep if the first command is successful). You could also look here for how to start playing a song with VLC: play-only-audio-with-vlc

Jeppe
  • 1,830
  • 3
  • 24
  • 33
1

If your npm install is part of a task, VSCode 1.72 (Sept. 2022) will offer:

add audio cue for task end and terminal bell

Fixes "Play sound upon completion of build so that users can multi-task (do work in other applications) and know when the build has completed "

Settings audioCues.taskEnded

This has been released to VSCode Insiders yesterday.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

For a slightly different solution there is a npm package named benny-hill:

Play the Benny Hill theme while running another command

e.g.

npx benny-hill npm install

will play Yakety Sax while you're waiting.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
0

for cmd like Terminals

Your_Command && [System.Media.SystemSounds]::Beep.Play()

Sounds: Beep, Hand, Quetsion, Asterisk, Exclamation

You can also play the raw sound and changes its pitch and duration [console]::beep(1000,500)

CrackerKSR
  • 1,380
  • 1
  • 11
  • 29
0

Actually there is a npm package doing exactly what you are asking for:

Literally tells you when a command is done running.

E.g.

npx okimdone npm install

It depends on external speech to text tools like espeak or festival to produce the audio.

hlovdal
  • 26,565
  • 10
  • 94
  • 165