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.

Including Natty I was always able to toggle (mute/unmute) the 'Master' sound volume with the

amixer sset Master toggle

command that I linked to an edge binding in CompizConfig-Manager.

Now after installing Oneiric the command only mutes the sound but doesn't unmute it. I even tried it in the Terminal but it also doesn't work. It changes 'Mono: Playback 68 [78%] [-14.25dB] [off]' to '...[on]' but the sound stays muted so that I have to unmute it via the 'sound-indicator' in the panel.

How can I get this working again? What did change since Natty? Does anyone know the command the 'sound-indicator' uses to toggle the sound volume?

share|improve this question
    
And to make it even more strange: on my other laptop, where I upgraded from Natty to Oneiric instead of a fresh install, it still works. –  joschi Oct 14 '11 at 6:42

7 Answers 7

up vote 10 down vote accepted

This works for me on 13.04, both mute and unmute:

amixer -D pulse set Master 1+ toggle

It specifies pulse audio to ensure unmute, unmutes everything.

share|improve this answer
    
Worked on lubuntu 13.10. Been looking for this for WEEKS! –  luisgonzalez Dec 10 '13 at 1:31
1  
EDIT: It only worked when running as a command in the terminal. But when i try to configure as a key binding I get: Home directory not accessible: Permission denied ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused amixer: Mixer attach pulse error: Connection refused –  luisgonzalez Dec 10 '13 at 1:44
    
It works even better without the 1+ parameter. –  J. Katzwinkel Oct 13 at 2:05

I'm using this script as a workaround:

#!/bin/bash

CURRENT_STATE=`amixer get Master | egrep 'Playback.*?\[o' | egrep -o '\[o.+\]'`

if [[ $CURRENT_STATE == '[on]' ]]; then
    amixer set Master mute
else
    amixer set Master unmute
    amixer set Front unmute
    amixer set Headphone unmute
fi

I did a diff of amixer scontents before calling amixer set Master mute and after calling it and unmuting everything using the GUI to figure out what needed to be unmuted.


  1. With sound on type amixer scontents > ~/before (you'll get a file with the status of all sound chanels)
  2. Then toggle volume with amixer set Master toggle
  3. Create a second chanel status file with amixer scontents > ~/after
  4. Toggle sound again with amixer set Master toggle which is supposed to turn the volume back to the level before the first toggle command
  5. Create a third file with amixer scontents > ~/afterafter

Now you have three files telling you which tell you the status of the sound chanels used for normal sound, which are muted by amixer set Master toggle and which aren't turned on again by again unmuting with the same command.

To easily compare the files and see the differences (the chanels that get muted and won't unmute afterwards) you can use meld from the Software Centre. Start it, open the three files and on the scrollbar you can see where there are differences between the files. Use the found chanel names to add them to the above described script.

share|improve this answer
    
Unfortunately the script only mutes sound but doesn't unmute it –  joschi Oct 24 '11 at 17:35
    
That's probably because your things that need to be unmuted aren't called "Front" and "Headphone" like they are on my system. –  Jim Hunziker Oct 24 '11 at 18:07
    
I also did a diff and found out what was missing for the script to work on my computer, now it works. Thanks a lot. –  joschi Oct 24 '11 at 20:11

Brute force unmute:

for i in $(amixer |grep -o \'.*\'); do amixer set $i unmute; done
share|improve this answer
1  
I don't think unmuting 80 and more devices is a good idea. This includes microphones, which can lead to unwanted feedback loops. do an for i in $(amixer |grep -o \'.*\'); do echo amixer set $i unmute; done before, to see what would be done. –  user unknown Apr 14 '12 at 22:29

If you want to replace amixer in .lircrc for your remotecontrol working with lirc, you can try following lines. Be sure to have xmacro installed. Volume-control now works again.

begin
        prog = irexec
        button = KEY_VOLUMEUP
        repeat = 1
        delay = 2
        config = echo KeyStrPress XF86AudioRaiseVolume KeyStrRelease XF86AudioRaiseVolume | xmacroplay $DISPLAY
end
begin
        prog = irexec
        button = KEY_VOLUMEDOWN
        repeat = 1
        delay = 2
        config = echo KeyStrPress XF86AudioLowerVolume KeyStrRelease XF86AudioLowerVolume | xmacroplay $DISPLAY
end
begin
        prog = irexec
        button = KEY_MUTE
        config = echo KeyStrPress XF86AudioMute KeyStrRelease XF86AudioMute | xmacroplay $DISPLAY
end
share|improve this answer

I couldn't get sound muting to toggle correctly. Whether I used CLI and type in Amixer sset Master toggle or hit the HP pavillion media toggle key, I get the same result: If sound is on and working, it will automatically turn off Master channel AND PCM channel. Then when I hit the toggle again (cli or key) it ALWAYS turns on Master, but leaves PCM muted. For my rig (HP Pavilion DV6 running Xubuntu Oneric), this means sound is off even with master on. When run from CLI - same results. If, with cli, I toggle PCM, it also turns off master channel and again won't turn it back on, though it toggles PCM correctly.

The script that worked was:

#!/bin/bash
    if amixer -c 0 get Master | grep -q off
then
    amixer set Master unmute
    amixer set PCM unmute

else
    amixer set Master mute
fi

Then I used Xubuntu keybindings (settings> settings manager> keyboard> application shortcuts) to browse to the script (I called it sndfx.sh and set it to executable by right clicking in thunar and under permissions ticked make executable). Then I assigned the HP Pavilion quickkey to it by tapping that key. Now, it toggles correctly - Awesome. Hope this helps someone else.

Peace

share|improve this answer

Try this script fragment...it works

https://wiki.archlinux.org/index.php/PulseAudio#volume_control

share|improve this answer
    
I confirm that this works on my setup, Can you write out the steps to implementing this, in current form it is not much use to other users. –  Mateo_ May 1 '12 at 4:50

If I'm not mistaken, it's a bug that causes other mixer channels to mute and unmute. To mute, try

amixer set Master 0;

To unmute try

amixer set Master 1%+; amixer set Master 7dB+;

share|improve this answer
    
These commands work, but they don't let me toggle the volume with a single command that I can combine with an edge binding. –  joschi Oct 24 '11 at 9:22
1  
If anyone's interested in the associated bug report see here. –  joschi Oct 24 '11 at 9:28

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.