1

Let's say I run a command which takes a long time to do its stuff, but I don't want or need to look at it the whole time, and as I need to do some other stuff as well I might get into that and forget to check on how the command is doing for some time... Then when I finally do check I may find that the command finished 3 hours ago and needed my attention then... Or perhaps it didn't need my attention, if I had seen that it had finished at the time I would have had more time to run more commands...

So I was wondering if there is a way to get it so that when a command or program has been run, whenever it finishes and returns to $, for it to make a little sound, like play an mp3 file or something? Though it would be acceptable just to get this working in gnome-terminal, I would like it in as many CLI environments as possible including the TTYs if that would be possible... I am running Ubuntu GNOME 15.10 with GNOME 3.18.

  • 1
    As for the duplicate question, pcspkr is disabled on newer versions of Ubuntu (works fine on debian and other linux distros) and so does not work unless you remove pcspkr from the blacklist and/or modprobe pcspkr. – mchid Mar 06 '16 at 20:19
  • @mchid do consider editing it. – muru Mar 06 '16 at 20:19
  • I found out how to get it to automatically beep after each command is run. I updated the answer and it is located after EDIT. – mchid Mar 08 '16 at 02:31

1 Answers1

5

First, run the following commands to enable pcspkr and to install beep:

sudo sed -i 's/blacklist pcspkr/#blacklist pcspkr/g' /etc/modprobe.d/blacklist.conf
sudo modprobe pcspkr
sudo apt-get install beep

Now, run a command along with beep like so:

sudo apt-get update; beep

or

sudo apt-get update; beep;beep;beep;beep;beep

Finally, to control the volume of beep, change the beep volume from alsamixer by running the following command:

alsamixer

Now, use your right arrow key to scroll to the automute option. Use the up arrow to toggle this off.

Then use the left arrow key to scroll to beep and use the up or down arrow key to raise or lower the volume of beep.

Use the M key to mute or un-mute any channel.

Press ESC to exit alsamixer

Many more options for beep can be found at:

man beep

EDIT

Now, to get the terminal to beep after each command is run, run the following command:

cp .bashrc .bashbackup
echo 'PROMPT_COMMAND="beep"' | tee -a .bashrc
. .bashrc
mchid
  • 43,546
  • 8
  • 97
  • 150
  • Can one use aliases or something to make it after every command without having to manually type beep after a command? –  Mar 06 '16 at 20:18
  • @ParanoidPanda I was thinking about that and I'm not sure. I think you might be able to add it by using $1 somehow but I'm not sure. – mchid Mar 06 '16 at 20:20
  • 1
    Well, if you ever do find out be sure to edit your answer and then ping me! ;) –  Mar 06 '16 at 20:23
  • @ParanoidPanda Just do an alias aub="sudo apt-get update; beep" – Fabby Mar 06 '16 at 20:34
  • @ParanoidPanda In case you didn't get notified, I added an edit so that you don't have to type beep after every command. – mchid Mar 23 '16 at 05:44
  • alsamixer does not show a beeper volume, but beep is working (loudly) – axd Dec 12 '17 at 13:42