How to enable shutdown sound on ubuntu 12.04 LTS and up

7,244

Solution 1

The "most simple" way would be to automate this process with a small bash script.

First, you need to take care of some dependencies by installing the mpg123 package, which can play mp3 files from the command line. You should be able to find similar packages for .ogg files as well.

sudo apt-get install mpg123

Next, you have to create the actual script that'll play the shutdown sound: (hint, you can replace pico with gedit if you don't feel comfortable editing files in the terminal. You can name the file whatever you want, but make sure you keep the K99 part in front of the file name for processing priority reasons.

sudo pico /etc/init.d/K99shutdownsound.sh

here's the content of the script:

#!/bin/sh
## play shutdown sound
/usr/bin/mpg123 /path/to/your/shutdown.mp3

make it executable:

sudo chmod +x /etc/init.d/K99shutdownsound.sh

Now you have to create a link from this script to /etc/rc0.d (where shutdown scripts go) and to /etc/rc6.d (where reboot scripts go)

sudo ln -s /etc/init.d/K99shutdownsound.sh/etc/rc0.d/K99shutdownsound.sh
sudo ln -s /etc/init.d/K99shutdownsound.sh /etc/rc6.d/K99shutdownsound.sh

And now you have a shutdown sound. Just make sure you're not going to play a 5 minute mp3 file, since the system won't halt until it finishes streaming the file.

Solution 2

What I used to do is have a file on my desktop called "Startup.sh" that would run a list of programs I like on startup. I discovered that when the last command in the list is playing a sound with mplayer it will do it right before shutdown OR logout. So, you need to download mplayer first: sudo apt-get install mplayer2

Then, make a file called "Startup.sh" on your desktop. The text of the file should read something like this:

#!/bin/bash
mplayer '[PATH TO SOUND FILE.extension]'

You just have to click that file every time you log in. You can add other startup programs you want to the script as well.

Share:
7,244

Related videos on Youtube

Joel Robert
Author by

Joel Robert

Updated on September 18, 2022

Comments

  • Joel Robert
    Joel Robert over 1 year

    I need a sound to play when I shutdown. In Kubuntu, there's shutdown sound. But Ubuntu, not anymore

    • Admin
      Admin almost 11 years
      You can install music123 to play .ogg, .wav and mp3 files in place of mpg123.
    • Luis Alvarado
      Luis Alvarado almost 11 years
      @JOHNNYG Please read askubuntu.com/faq if you still want to create an answer for this question.
  • Joel Robert
    Joel Robert over 8 years
    I recomend to use package 'music123' as it supports any kind of sound format such as mp3, ogg, wav, etc. etc.
  • Joel Robert
    Joel Robert over 8 years
    KXX (XX is number of order) is ordered in asciibetical. using number 99 for the external script will probably fail to sound because the sound has been disabled at certain number of order. Try to experiment by putting the shutdown sound order into first priotity into 'K01shutdownsound.sh' and don't forget to make it executable as well (make sure it has been, double check it). Just leave the current 'K99shutdownsound' script and link intact.
  • phil294
    phil294 almost 7 years
    why did you use #!/bin/sh instead of bash? and why is the path to mpg123 needed?