-
-
Save taterbase/3154646 to your computer and use it in GitHub Desktop.
function alertTerminal(){ | |
console.log("\007"); | |
} |
Look this https://github.com/JayrAlencar/node-beep
If anyone else comes by confused by process.stderr.on("\007");
it should be process.stderr.write("\007");
instead.
No sounds with any of the following on macOS High Sierra, node 8.10.0:
$ node --version
v8.10.0
$ node
> console.log('\x07')
> console.log('\007')
> console.log('\u0007')
> process.stderr.write('\x07')
> process.stderr.write('\007')
> process.stderr.write('\u0007')
node-beep
seems to be built only for windows.
@aneilbaboo You need to unfocus the terminal tab/window and make sure the "Audible bell" setting is enabled
in Preferences > Advanced
$ node
> setTimeout(() => console.log('\x07'), 1250)
// Unfocus the terminal before the timeout expires.
Thanks @aleclarson . I needed to unclick 'Silence bell' in my iTerm 2 profile under 'Notifications'
Is it possible to change the beep frequency and duration with nodejs? Some languages have something like: Beep(hertz, milli)
(https://stackoverflow.com/questions/38883092/how-to-make-motherboard-beep-through-c-code)
Or
SoundBeep, Frequency, Duration
(AutoHotKey: https://www.autohotkey.com/docs/commands/SoundBeep.htm)
in git bash terminal
echo -e "\a"
@mayeaux Mine didn't work because I was running the code in VSCode terminal, after switching to main terminal it worked
windows or wsl
require("child_process").exec("powershell.exe [console]::beep(500,600)");
Mac
require("child_process").exec("afplay /System/Library/Sounds/Glass.aiff");
Yeah, for some reason in VScode terminal it doesn't sound, in main terminal it works. Thanks for the tip!
windows or wsl
require("child_process").exec("powershell.exe [console]::beep(500,600)");
Mac
require("child_process").exec("afplay /System/Library/Sounds/Glass.aiff");
Thank you very much!
http://stackoverflow.com/questions/8557624/how-i-trigger-the-system-bell-in-nodejs
console.log('\u0007');