How do I make Ubuntu sound like HAL, from the movie 2001: A Space Odyssey?

Solution 1:

Getting Ready

  • Download the HAL sounds and store them in a folder, let's say ~/audio/hal/
  • EDIT : as pointed by @M. Becerra in comments, stoutman.com is now broken. More HAL sounds are available in The 2001 Archive.
  • We are going to use function.wav, cantalow.wav, 1moment.wav, better.wav goodbye.wav, and message4u.wav (old sounds from stoutman.com, find your own custom sounds from the link above).
  • Of course, you can use many other sounds and customize your own HAL!
  • We will use paplay from the PulseAudio server, so there is nothing else to install.

1. Startup: "All systems are functional"

This section explains how to play a sound on session opening (source).

  • Create a .conf file in ~/.config/upstart/:

    gedit ~/.config/upstart/halsayshello.conf
    
  • Copy and paste this content:

    start on startup
    task
    exec paplay ~/audio/hal/function.wav
    
  • Save file, exit gedit, and HAL should now speak on next session opening.

2. Shutdown: " That's something I can not allow to happen..."

This section explains how to play a sound when a non-sudo user tries to use shutdown. The sudo -v command before paplay is here to ask the password prompt before playing a sound. If you don't care playing the sound before prompting for the password, you can delete it:

  • Add this line at the end of ~/.bashrc file:

    alias shutdown='paplay ~/audio/hal/cantalow.wav'
    
  • Yet, if you want the user to be able to shutdown, replace it by:

    alias shutdown='sudo -v && paplay ~/audio/hal/goodbye.wav && sudo shutdown'
    
  • Enable changes:

    source .bashrc
    

3. Upgrade: "I feel much better now. I really do."

This section explains how to play a sound after upgrading packages with apt:

  • Add this line at the end of ~/.bashrc file :

    alias upgrade='sudo apt update && sudo apt upgrade && paplay ~/audio/hal/better.wav'
    
  • Enable changes

    source .bashrc
    
  • You can now execute the upgrade command in your terminal

4. Reboot: "One moment please..."

This section explains how to play a sound before reboot.

  • Add this line at the end of ~/.bashrc file:

    alias reboot='sudo -v && paplay ~/audio/hal/1moment.wav && sudo reboot'
    
  • Enable changes:

    source .bashrc
    
  • You can now reboot using reboot instead of sudo reboot.

5. Email notification: "There is a message for you"

  • Move to default system sound folder:

    cd /usr/share/sounds/freedesktop/stereo
    
  • Backup default message notification sound:

    sudo mv message.oga message.oga.bak
    
  • Copy ~/hal/mesage4u.wav to replace it:

    sudo cp ~/audio/hal/mesage4u.wav message.oga
    

That's it

Well, of course these are just examples of what can be done. I wanted to share that funny configuration I set up, not on my computer, but on a home server (with speakers). Much more can be done or must be done if you want to play this sounds as root, or add others for more commands.

I'm exited about your ideas to improve it.

Enjoy your HAL and ... stay safe.