Ubuntu – How to play a sound when laptop gets unplugged

batterynotificationsound

My laptop unplugged stands 1 minute. Previous week my laptop cable, started not connecting good with the laptop.

I would like to play a certain sound everytime it gets's unplugged so I can hurry and connect them good.. Anyone?

Best Answer

As explained in this answer, you have to:

  1. cd into your home folder and create the directory .local/share/sounds:

    cd && mkdir -p .local/share/sounds
    
  2. cd into the newly created directory:

    cd .local/share/sounds
    
  3. place the desired sound inside the directory, renaming it as power-unplug.wav (for example in this way):

    ln -s /usr/share/sounds/alsa/Noise.wav power-unplug.wav
    
  4. test the event with:

    canberra-gtk-play -i power-unplug
    

I suppose that, at this point, you have to logout and log back in to have the event work properly. Try it and see if it works. You can find more events and sound names here.

Related Question