Play a sound or notify when npm install is done
Asked Answered
I

6

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.

Income answered 24/1, 2020 at 8:27 Comment(1)
Perhaps npm install; [search on how to make a sound from bash], e.g. this - ; instead of && since you may want an alert even if it fails.Industrious
I
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

Industrious answered 28/1, 2020 at 18:4 Comment(3)
Can we add this such that it is executed after every npm install ? Like a global postinstall script.Guppy
Unless supported by npm, I doubt it is possible. You could create an alias in that case.Industrious
Alias sounds like the way to go here. Thanks.Guppy
F
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.

Femur answered 16/9, 2022 at 22:2 Comment(0)
B
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.

Bookcraft answered 17/1, 2023 at 17:43 Comment(0)
B
1

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.

Bookcraft answered 17/1, 2023 at 23:2 Comment(0)
V
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)

Vexed answered 4/7, 2022 at 19:10 Comment(0)
S
0

There are two terminal audio signals that are helpful here:

Accessibility > Signals: Terminal Command Succeeded
Accessibility > Signals: Terminal Command Failed

These are settings you can find in your Setting UI. You will probably need to change the volume, search for "signals volume" in your Settings UI.

Spouse answered 5/6 at 21:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.