How do i find exact status of my microphone mute or unmute or the volume level of mic using command line?

7,887

Solution 1

By using the Pulseaudio Command Line Interface we will obtain a lot of information on available sources

pacmd list-sources

will display a rather lengthy list. The current active input is marked with an asterisk. We could combine this with grep but will then lose information for which source the outputs are valid

pacmd list-sources | grep volume

To set an output to a defined value we need to know it's index which is also given by list-sources to issue

pacmd set-source-volume <index> <value> # value: 0 = mute 65536 = 100%

We may also need to unmute the sink source with

pacmd set-source-mute <index> 0

Solution 2

You access this information with amixer. To list all sound controls you can issue the command

$ amixer controls
...
numid=18,iface=MIXER,name='Capture Source'
numid=19,iface=MIXER,name='Capture Switch'
numid=20,iface=MIXER,name='Capture Volume'
...

and then read the values of the controls with

$$ amixer cget numid=20
numid=20,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=15,step=0
  : values=0,0
  | dBscale-min=0.00dB,step=1.50dB,mute=0

Check out the man pages of amixer. Interesting is also alsamixer, which gives you a more intuitive command line interface.

Solution 3

This is a simple solution to toggle/untoggle the microphone mute with one line

I believe this helps

I created a mictoggle online script

$ cat /usr/local/bin/mictoggle

pactl list sources | grep -qi 'Mute: yes' && pactl set-source-mute 1 false || pactl set-source-mute 1 true
Share:
7,887

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    This is very odd, i have one default microphone and i have another second microphone. When i use this command it always shows not muted but the microphone volume is 0%. How or what is a way i can find those value accurately.

    $ pactl list | sed -n '/^Source/,/^$/p' | grep Mute
        Mute: no
        Mute: no
        Mute: no
    
  • Greg Mueller
    Greg Mueller over 2 years
    I agree with guntbert that this is not what the OP asked and yet I up voted because it is exactly what I was looking for.