Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I listen to music almost any time I am on my computer. I often accidentally unplug my headphones. This has resulted in disturbing others around me. Does any one know of a way to mute the speakers (and potentiality pause VLC) when headphones are unplugged?

I would like to do this on my Laptop. It is an Acer Aspire One D150. The speakers are built-in to the computer. My headphones are standard 1/8 in which connect through the headphone jack.

share|improve this question
    
Maybe you should also give info about your speakers & headhones (e.g. how they are connected). –  JanC Oct 13 '10 at 21:32
add comment

3 Answers

up vote 1 down vote accepted

My original answer was simply "Just click on sound preferences, and choose to use "analog headphones" in the "output" settings. Let me know if this doesn't help."

EDIT/UPDATE: okay, this may not work nicely if you have your alsa configured so that it automatically mutes speakers when headphones are plugged in. You may need to disable that if you have it set.

Anyway, get some music anything with sound playing so you can test your sound output. Now open your Terminal console and type alsamixer. Check it out. Pretty cool, right? Here, you can adjust the volume levels for master, headphone, speaker, as well as other inputs/outputs.

In alsamixer, set your volume how you want it for when your speakers are on. Headphones can be at any volume you like. I'd put your "speaker" at 100% and your master at ~75%. We are going to save this in a profile now! Hit escape to exit alsamixer. If you open it again, you will see that your settings are still saved.

After you have set volume how you want it for having your speakers on, type in the console, alsactl -f filename store except change "filename" to whatever you want to call it. I called mine noheadph.alsa. Now go back into alsamixer and set your headphone volume up, and your speakers at 0%, leaving master volume wherever you prefer it. Exit alsamixer by hitting escape, and save this profile by typing alsactl -f filename store except this time, replace "filename" with something relevant, such as "headph.alsa". Now, you can recall/restore to either of these profiles by typing alsactl -f filename restore obviously replacing "filename" with whatever you named your stored profiles. Isn't this cool?! Note that the profiles should be stored in your home user directory.

What's left? Just bind a keystroke restore one profile, and another to restore the other one! How? On the OS menu Go to System> Preferences> Keyboard Shortcuts. Here, click "add" to add a new shortcut. I named mine "set soundout headphones only" and entered the command alsactl -f /home/username/headph.alsa restore except change "username" to your user account name. I think you get the gist! :)

Please tell me how it goes for you. Thanks to this thread for the alsamixer info, etc.

P.S. Unfortunately, I can't just use $home/filename in the keystroke command for some reason. Anyone know why this is???

share|improve this answer
    
This is the best solution, but doesn't work the way I would like it to. I would like to either automatically do this or allow me to toggle this by running a command. –  JasonCook599 Nov 19 '10 at 20:07
    
There is a way to do it via console, so there is a way to do it via script (and also by keystroke). I have to look into it. –  Slink Dec 14 '10 at 6:08
    
figured it out! look at my answer for a new edit in a moment... –  Slink Dec 14 '10 at 8:00
    
I just tested it with headphones. I have something enabled which I would call "auto-mute on headphone detect" (I edited some config file via tutorial in the past). My solution in the answer above works as well as I could possibly imagine it working! :) Cheers. Enjoy. –  Slink Dec 16 '10 at 8:26
    
Update: you will notice that despite the master volume in alsamixer, your most recent system volume setting will "pick up where it left off" once you try to adjust the volume using the laptop's XF86Audio volume control buttons. –  Slink Dec 17 '10 at 9:57
add comment

As far as I'm informed there is no default option on order to resolve this matter. You could try the following:

  1. Default mute the speakers.
  2. If this doesn't work then you could disable the speakers output to prevent this from happening.

Regards, Martijn

share|improve this answer
    
What do you mean "Default mute the speakers"? I understand the second suggestion, but this doesn't doe what I want. Is there a way to change this from the CLI? If I could just run a command to turn them on and off the second option would work much better. –  JasonCook599 Oct 14 '10 at 22:32
    
I meant that you could mute the speakers. This way they wont make any sound when you unplug your headphone. If you decide that you want to use your speakers you simple unmute them. –  KYI Oct 16 '10 at 10:24
    
I may not have mentioned this, but this on my laptop. I don't know of any way to mute my speakers without muting the headphones. –  JasonCook599 Oct 18 '10 at 23:00
add comment

As KYI said, You could try mute the speakers. Maybe this page will help You.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.