Sound on command exit

Sebastian Taralunga seba at tcx.ro
Sat Apr 15 05:29:56 EDT 2000


A simple way to get a beep on exiting a command is:

command; echo ^G

Where ^G is a real ^G and not just the characters ^ followed
by G. That is, in order to use it you have to press ^V
followd by ^G ( ^V tells the shell that a real ^G is
following ).

^G is similar to a beep; if one beep is not enough you can
use a command line like: 

command; echo ^G; sleep 1; echo ^G; sleep 1; echo ^G

which would give you three beeps with one second delay
between them.

You can also use a command like: 

alias f='echo ^G; sleep 1; echo ^G'

in your .profile so that you can alias f to two beeps with
one second delay between them, from now on you can use

command;f

and here it is!

Alternatively you can do is do create a small shell script
(say f) which you should place in one of the paths from your
$PATH; this script whould look like: 

#! /bin/sh 
echo ^G; sleep 1; echo ^G

which does exactely the same thing.

This is the difficult way to accomplish that. 


But from far away the most simple is to use a real ^G in
your $PS1 variable like this:

PS1='\h:\w\$ ^G'

The PS1 variable is the one which tells the shell what to
print as the command prompt. It is usually intialised within
the /etc/profile, and it looks differently for the root or
for the normal user. You can always change the value of this
variable and the changes take effect immediately. You can
change it's value within the .profile if you  want a very
personalised profile. 

Now, on my system which is Slackware, the value of PS1 is
\h:\w\$ which means: the prompt shows me the hostname, the
current working directory and a $; so what I did I change
this and I added a ^G which means that any time I eiher
press enter or exit a command I will hear a beep. 

Please don't hesitate to ask any question if you need, I 
really hope this helps, 

Have a nice day, 

Sebastian
  
On Fri, 14 Apr 2000, Victor Tsaran wrote:

> Hello, listers!
> Some of you have asked previously whether it is possible to have some sort
> of beep after certain command exits or certain task terminates. Yesterday I
> was playing around with Linux with another friend of mine, Luke Davis, who
> is yet another Linux user from Philadelphia. Accidentally, we recalled that
> Unix allows one to specify several commands on a single command line by
> dividing these commands with a semicolon. So, for instance, to run pine
> after your lynx exits you could enter:
> 
> lynx; pine <ENTER>
> 
> The Pine would fire up as soon as you quit Lynx. that opens a lot of
> interesting possibilities for providing temporary sound solutions to
> indicate termination of a background task or any other event. You could
> either run `play' command with your beloved .wav file on the command line or
> you could create a very short script called beep and exploit it.
> Say, we have a file called beep_when_you_re_done.wav and you'd like to know
> when your kernel finishes compiling. You might enter:
> 
> make bzImage output.txt 2>&1 &; play beep_when_you_re_done.wav
> 
> Now you can safely switch to another console and do other things. When "make
> bzImage" is finished, it will play the file.
> 
> Hope this can help someone.
> Regards,
> Victor





More information about the Speakup mailing list