Shing Lyu

Generating a notification sound in command-line

By Shing Lyu    

Disclaimer: This content reflects my personal opinions, not those of any organizations I am or have been affiliated with. Code samples are provided for illustration purposes only, use with caution and test thoroughly before deployment.

You want to play a notification sound in a Linux shell script, but don’t want to download any sound files (e.g. MP3, WAV, MIDI). Here is a script that generates the sound on-the-fly:

First install SoX, the Swiss Army knife of sound processing programs.

sudo apt-get install sox

Then:

play -n synth 0.3 pluck A3 vol -20dB repeat 2

Want to learn Rust? Check out my book: