A lot of users are facing noise problem when headphones are connected and are fed up with it just like I am. This solution is for them. There are a lot of solutions given on askubuntu but none have worked for me.
Things were good when I used Windows 8.1. There was no such sound issue. Well, but now I am on Ubuntu and I have no plans of going back to Windows.
I have accepted the fact that my laptop's sound system is not shielded properly.
I haven't addressed the root of the problem, but just kind of made it a virtually unnoticable.
So, the hack is quite simple. As the problem persists only when there is no playback, I came up with a hack to always have a playback!
Now, this should be true only when the headphones are connected. And the playback should stop when headphones are removed.
Follow these simple steps-
Step #1: Install mplayer and configure it.
sudo apt install mplayer
type in that file->
Step #2: Download this mp3 file from here (silence-10sec.mp3)
Step #3: Create a folder in home directory and name it
Copy the mp3 file in your
cp ~/Downloads/silence-10sec.mp3 ~/.hush/
In that folder, create a script file and name it
Copy paste this code in the script file.
plugged="jack/headphone HEADPHONE plug"
unplugged="jack/headphone HEADPHONE unplug"
acpi_listen | while IFS= read -r event;
if [ "$event" == "$plugged" ]
mplayer -really-quiet -loop 0 ~/.scripts/silence-10sec.mp3 &
elif [ "$event" == "$unplugged" ]
pkill -f mplayer
Make it executable with the command
chmod +755 silence.sh
Step #4: Type
startup applications in the Dash and add the path of silence.sh script to it.
So, basically what we are doing is listening to events of headphones been connected and disconnected and playing or stopping the blank mp3 file in a loop. Now, I have used
mplayer because I know that I am never gonna use that for any other purpose and killing its process is completely safe for me.
I came up with this idea when Serg answered to one of my questions.
He came up with this script and I just made modifications to it to suite the requirement.