In a bash script/command how can I make a PC beep noise, or play a sound file?

Try this:

echo ^G

(^G is obtained by ctrl+G).

Note: you can't copy and paste this code in a batch file, it won't work. To obtain a ^G character in a file, type in a cmd window:

echo ^G > beep.txt

(again, ^G is obtained by ctrl+G).

Then you'll have a file named beep.txt, open it with notepad, there will be a square character. This is our ^G once it is saved in a file.

You can then copy and paste it in a batch file to make a sound (don't forget to put "echo" in front of it).


spd-say

sleep 2; spd-say 'get back to work'

Infinite loop with -w if you need extra motivation:

sleep 2; while true; do spd-say -w 'get back to work'; done

or if you prefer the carrot:

sleep 2; while true; do spd-say -t female1 -w "I'm done, come back to me, darling"; done

Pre-installed on Ubuntu 14.04 via the package speech-dispatcher: http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.manifest for blind people I suppose?

See also: https://askubuntu.com/questions/277215/how-to-make-a-sound-once-a-process-is-complete

Also add a popup

This combo is a life saver, b stands for beep:

b() ( spd-say 'done'; zenity --info --text "$(date);$(pwd)" & )

and then:

super-slow-command;b

If I'm somewhere in the room, I'll hear it and know that the long job is done.

Otherwise, I'll see the popup when I get back to my computer.

Related: How to show a GUI message box from a bash script in linux?

Listen to your cooler

I'm joking of course, but for compilation I noticed that I use often use this queue subconsciously. When the cooler stops humming for a while, it means that the compilation is over!


This will make a beep from within bash

echo -en "\007"

I know your question was for Window but just putting this here for any Mac OSX users who come across this article. OSX 10+ comes with the say command:

say "I'm done"

For example:

sleep 5 && say "I'm done waiting 5 seconds"

Tags:

Shell

Audio