Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have started a long process through a terminal. Is it possible to make the Ubuntu terminal make a sound once the process is complete? This way, I don’t need to keep checking, but will instead be notified through a sound.

share|improve this question
    
Can you explain further what do you mean with process complete? –  Lucio Apr 2 '13 at 18:21
    
@Lucio control is returned back to the terminal –  Goaler444 Apr 2 '13 at 18:23
1  
Do you mean, open an application from terminal and when it finish, make a sound? Do you have an Ubuntu server or you mean GUI software? –  Lucio Apr 2 '13 at 18:24
2  
yes exactly. For example i start a command line program, and once it exits and control is returned back to the terminal, a sound is made. I am currently using Ubuntu 12.10 –  Goaler444 Apr 2 '13 at 18:31

1 Answer 1

up vote 15 down vote accepted

There are at least three command line ways to accomplish this by putting the suiting command at the end of your script you may invoke for your lengthy process:

  1. The "classical" way to play a sound is to use beep Install beep through the PC speakers. However this will not work in all cases (e.g. in my system PC speakers are completely disabled).

    beep [optional parameters]
    
  2. We can also play any sound file in wav format using aplay (installed by default):

    aplay /usr/share/sounds/alsa/Side_Right.wav
    
  3. Another way is to use the pulseaudio command line interface to enable playback of any sound files your system recognizes:

     pacmd play-file /path/to/sound.file <index/name>
    

    Replace the <index/name> with the index or name of output sink desired, e.g.:

     pacmd play-file /usr/share/sounds/freedesktop/stereo/complete.oga 1
    

We can use default sound files from /usr/share/sounds/, or any other sound file we may have in a different location.


Just to have mentioned it, there is another nice way to achieve this by misusing espeak, which is installed by default in Ubuntu <= 12.04. See, or rather hear the following example:

#! /bin/bash

c=10; while [ $c -ge 0 ]; do espeak $c; let c--; done; sleep 1 ## here lengthy code
espeak "We are done with counting"

In Ubuntu >= 12.10 Orca uses speak-dispatcher. We can then install espeak Install espeak, or alternatively use spd-say "Text".

share|improve this answer
    
thanks, went for option 2 :) –  Goaler444 Apr 2 '13 at 19:42
1  
@Takkat I'm using Ubuntu 12.10 and espeak is currently not installed. –  Lucio Apr 2 '13 at 20:55
    
@Lucio: yeah, now that you say it... They switched to speak-dispatcher. If this works (it does not on my system) see edit for using spd-say. –  Takkat Apr 2 '13 at 21:07
    
@Takkat The spd-say utility is installed by default and it works on my system. –  Lucio Apr 2 '13 at 21:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.