Stop sound from speakers when connecting headphones

Follow these steps to automatically mute your speakers when plugging in headphones:

  1. Open Terminal (Ctrl+Alt+T)
  2. Type: alsamixer and press Enter/Return
  3. Select the correct sound device by pressing F6
  4. Navigate to the right with (Right Arrow key) until you highlight Auto-Mute
  5. Press (Up Arrow key) and select Enabled (or Line Out)
  6. Press Esc to exit

Original Solution

  1. Go to Realtek official site, accept the disclaimer, then download the audio driver for linux/unix. You need to select version 3 for Kernel 3 or later.

  2. Setup necessary tools to compile this driver.

    sudo apt-get install build-essential gcc make

  3. Extract the downloaded file, run sudo ./install file from a terminal after going to the extracted folder to compile the driver.

  4. Read the Readme.txt file for more information.

  5. Install gnome-alsamixer by this command.

     sudo apt-get install gnome-alsamixer
    
  6. Open the gnome-alsamixer by typing alsamixer in the dash.

  7. Select the "Auto mute mode" in the new window.

Reboot and see whether it fixed now. (Step 6 and 7 might not necessary). Automute will automatically enabled upon restart


Solution 2:

I have just found another solution:

(It worked for me with Only S/PDIF profile, Sound from both headphone and speaker and not being able to switch profile)

  1. Add this ppa by the command

      sudo apt-add-repository ppa:ubuntu-audio-dev/alsa-daily
    
  2. Update packages list. by

     sudo apt-get update
    
  3. Then install "alsa-hda-dkms" package:

      sudo apt-get install alsa-hda-dkms
    

Reboot, And See the result!


I also had this problem on my HP laptop. I found a post and take one of the advice, which suggests adding two lines to the bottom of the file /etc/modprobe.d/alsa-base.conf:

options snd-hda-intel model=laptop
options snd-hda-intel position_fix=1 enable=yes

save it and reboot. It works for me!