9

I need to mute/unmute from the command line. I found out that I can do it with:

amixer sset Master mute
amixer sset Master unmute

the problem is that the command for unmute is not working (as described also in this bug report: https://bugs.launchpad.net/ubuntu/+source/alsa-utils/+bug/878986)

My question is: is there another way to obtain the same result, taken that amixer is not working?

Furthermore, if I set manually the volume to minimum and then call

amixer sset Master 100%

the volume increases but doesn't switch to maximum, even if the stdout tells:

Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 31 [100%] [0.00dB] [on]
Front Right: Playback 31 [100%] [0.00dB] [on]

Can anybody help me with this?

earthmeLon
  • 11,247
giuspen
  • 383
  • It seems to be working perfectly for me. I don't user 'Master', however. Have you tried setting different controls? Does it work if you use Front vs Master? Open alsamixer to view which options you have. – earthmeLon Nov 09 '11 at 17:16
  • I tried also with 'Speaker' and 'Headphone' but same result, I also tried on other pc and laptop and still the same result: mute works, unmute doesn't – giuspen Nov 10 '11 at 20:52
  • 1
    Can you try amixer -c 0 set Master playback 100% unmute in a terminal and see if it works. – Mark Rooney Mar 02 '12 at 09:47
  • It works only if I did not mute from the command line but from the gui (11.10). If I mute from the command line then I cannot unmute. – giuspen Mar 03 '12 at 11:53
  • if I do "amixer -c 0 set Master playback 0% mute" and "amixer -c 0 set Master playback 100% unmute" it works!!! Thanks!!! – giuspen Mar 03 '12 at 11:57

7 Answers7

16

Even better is this one, unmute all audio devices. and set volume to 70%

for x in `amixer controls  | grep layback` ; do amixer cset "${x}" on ; done


for x in `amixer controls  | grep layback` ; do amixer cset "${x}" 70% ; done

in the example above the HDMI and optical isn't unmutted..

psukys
  • 3,590
ThcTLo
  • 161
  • 1
  • 3
  • Thanks. The commands in other answers, such as 'amixer -c 0 set Master playback 100% unmute' or 'amixer set Master unmute' did not work for me (even if I mute via 'amixer set Master mute'). – djb Apr 02 '14 at 16:03
8

Try the following commands in a terminal

amixer -c 0 set Master playback 0% mute
amixer -c 0 set Master playback 100% unmute

This should ensure all outputs are controlled. It's likely with your posted commands the reason the volume is not 100% is that the amixer does not release all outputs eg headphones or any other sound outputs at the same time.

Mark Rooney
  • 6,289
5

Get all sounds sources, get their names, form a command line with amixer and execute it

amixer scontrols | grep -oE "'.*'" | awk -F\' \
 '{print "amixer -c 0 set \""$2"\" unmute 100"}' | sh

Unmutes all audio devices and sets their volume to max.

Have a great one, Mike

muru
  • 197,895
  • 55
  • 485
  • 740
Mike
  • 51
  • 1
  • 2
  • This one works good for me, the only thing left unmentioned is that this sets PCM to a hard value of 100 out of a ceiling 255, so the volume will be a little quiet. You can further adjust this with amixer -c 0 set PCM 100%. (@Kubuntu 18.04/awesomewm) – irbanana Jul 06 '18 at 17:30
2

Mark Rooney's solution did not work for me, but I was able to work around this by explicitly unmuting all of the channels.

#!/bin/bash

for i in Master Headphone PCM Front Surround Center LFE Side; do
    amixer -c 0 set "$i" playback unmute
done &>/dev/null

I got the channel names but running alsamixer.

kos
  • 35,891
1

Ok, first you need to know your different card numbers from

alsamixer

select cards from F6 and note the card number that has Master option

If you use headphones, then we change both Master and Headphone

amixer -c 1 set Master toggle && amixer -c 1 set Headphone toggle

where -c specifies the card number, 1 in this command.

0

The commands you are using doesn't work for me either, but try these. They work for me.

amixer set Master 0
amixer set Master 100
per
  • 1
  • with your commands the volume is lowered/raised but not to minimum/maximum as I would need – giuspen Nov 10 '11 at 08:54
  • This solution won't raise the volume sufficiently. remember that the ranges for the volume control is 0 to 65536. amixer set Master 65536 will set the volume to maximum. – Sudip Bhattarai Mar 02 '21 at 04:19
0

The accepted answer from Mark Rooney didn't help me because that command gave me an error (my sound card has number 1):

amixer: Mixer attach hw:1 error: Invalid argument

So I tried

amixer set Master 100 unmute

and it worked perfectly for currently selected sound card. You can also mute it using

amixer set Master 0 mute