How do I mute the pulseaudio microphone at startup? Or remember its state at shutdown?

Let me start by saying my audio is working fine.
However I like my (build-in) microphone to be muted at all times and I only unmute it if I have, e.g., a conference call.
The last 3 Manjaro updates presented me with an undesired, desired and the last update again an undesired result. Meaning that the update before the last, the pulseadio setting where kept. so when I had the microphone muted at shutdown the system would startup with the microphone muted.
But currently the system will always startup with the microphone unmuted.

So can anyone help me to find the configuration setting that will, once and for all, always mute my (build-in) microphone at startup?
Thanks.

>> uname -a
Linux HOSTNAME 6.1.67-2-MANJARO #1 SMP PREEMPT_DYNAMIC Tue Dec 12 00:54:25 UTC 2023 x86_64 GNU/Linux
>> inxi -A
Audio:
  Device-1: Intel 100 Series/C230 Series Family HD Audio driver: snd_hda_intel
  API: ALSA v: k6.1.67-2-MANJARO status: kernel-api
  Server-1: PipeWire v: 1.0.0 status: active
  Server-2: PulseAudio v: 16.1 status: active
>> pacmd dump
### Configuration dump generated at Mon Dec 18 22:01:12 2023

load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
load-module module-augment-properties
load-module module-switch-on-port-available
load-module module-udev-detect
load-module module-alsa-card device_id="0" name="pci-0000_00_1f.3" card_name="alsa_card.pci-0000_00_1f.3" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"
load-module module-jackdbus-detect channels=2
load-module module-bluetooth-policy
load-module module-bluetooth-discover
load-module module-bluez5-discover
load-module module-dbus-protocol
load-module module-native-protocol-unix
load-module module-gsettings
load-module module-default-device-restore
load-module module-always-sink
load-module module-intended-roles
load-module module-suspend-on-idle
load-module module-console-kit
load-module module-systemd-login
load-module module-position-event-sounds
load-module module-role-cork
load-module module-filter-heuristics
load-module module-filter-apply
load-module module-x11-publish display=:0.0 xauthority=/xx/.Xauthority
load-module module-x11-xsmp display=:0.0 xauthority=/xx/.Xauthority
load-module module-cli-protocol-unix

set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo 0xbdc7
set-sink-mute alsa_output.pci-0000_00_1f.3.analog-stereo no
suspend-sink alsa_output.pci-0000_00_1f.3.analog-stereo yes

set-source-volume alsa_output.pci-0000_00_1f.3.analog-stereo.monitor 0x8ccc
set-source-mute alsa_output.pci-0000_00_1f.3.analog-stereo.monitor no
suspend-source alsa_output.pci-0000_00_1f.3.analog-stereo.monitor yes
set-source-volume alsa_input.pci-0000_00_1f.3.analog-stereo 0xa186
set-source-mute alsa_input.pci-0000_00_1f.3.analog-stereo yes
suspend-source alsa_input.pci-0000_00_1f.3.analog-stereo yes

set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo

set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
set-default-source alsa_input.pci-0000_00_1f.3.analog-stereo

### EOF
1 Like

Welcome to Manjaro forum @2old4it

Reboot system and check mute state of microphone source

pactl get-source-mute alsa_input.pci-0000_00_1f.3.analog-stereo

If response is Mute: no use this command to mute the source

pacmd set-source-mute alsa_input.pci-0000_00_1f.3.analog-stereo 1

Not a sollution to your pulseaudio problem but

Unless pulseaudio is a demand on your side I recommend switching to pipewire.

Edit

Nvm. Not sure why you have both installed and use pulseaudio. I guess if you have a reason for it you can ignore my message here.

But that might be the reason, disable it in pipewire and see if it fixes it.
Or disable pipewire. :person_shrugging:
I would only use one or the other though.
pulseadio = legacy
pipewire = new (things just work)

I think pipewire will be very useful/required with wayland too, whenever you have to move over.

Doesn’t this get covered by amixer?

I get this:

> amixer scontrols
Simple mixer control 'Master',0
Simple mixer control 'Capture',0

Generally I set the volume low on suspend and raise it for my morning alarm:

amixer set Master 20% before suspend.
amixer set Master 60% after wake.

You can do your microphone like this:
amixer set Capture 0%

I must state, however, that I’m using pipewire - not sure how similar it is, just open audio controls and try them in your terminal or krunner.

Then you can put them in a simple script:

#!/usr/bin/env bash
amixer set Capture 0%
kdialog --passivepopup "Microphone is muted" 4

Looks good, add to autostart.

@bedna
If pacmd command works OP must be using PulseAudio as default audio server
PipeWire media server is not likely to be causing a problem with microphone mute state

@Ben
amixer commands would be another option if changing the mute state via pacmd does not persist

amixer sset Capture nocap

But OP would probably have to turn audio capture on to use microphone because ALSA capture state cannot be changed in pavucontrol or VOIP audio controls

amixer sset Capture cap

@nikgnomic
Thanks for the suggestions.
However:

pacmd set-source-mute alsa_input.pci-0000_00_1f.3.analog-stereo 1

does mute my microphone but it doesn’t persist after a reboot.
Neither does the:

amixer sset Capture nocap

@bedna
I do not know why both PipeWire and PulseAudio are installed, I installed Manjaro 6-7 years ago and updated it ever since. So maybe PulseAudio is there because it is legacy and still supported and PipeWire is probably there because it is a dependency for one of the packages I installed (most likely osb-studio).

For PulseAudio use this command to add mute state control to custom user configuration:

tee ~/.config/pulse/default.pa <<< '.include /etc/pulse/default.pa
.nofail
set-source-mute alsa_input.pci-0000_00_1f.3.analog-stereo 1'

Restart pulseaudio units to check mute setting persists

systemctl --user restart pulseaudio

obs-studio requires pipewire multimedia server but not pipewire-pulse audio server

If pipewire systemd units are just disabled they will restart when system is rebooted
but they can be masked if not needed:

systemctl --user disable --now pipewire.socket pipewire.service; systemctl --user mask pipewire.socket; systemctl --user mask pipewire.service

Well this is unexpected.

Adding your suggestion to ~/.config/pulse/default.pa doesn’t work. After a reboot the microphone gets unmuted.

BUT masking the PipeWire systemd units (socket, service) does work.
Even if I remove the ~/.config/pulse/default.pa file the system boots with the choice I made at shutdown (mute/unmute).
So I guess pipewire does have an effect on the state of the microphone.

BTW: I don’t have pipewire-pulse installed. Only pipewire, libpipewire, pipewire-audio, pipewire-jack and pipewite-media-sessions

Looking at the ~/.config/pipewire-media-sessios/default-routes I see:

alsa_card.pci-0000:00:1f.3:input:analog-input-internal-mic mute:1 volumes:2,0.063093,0.063093
alsa_card.pci-0000:00:1f.3:output:analog-output-speaker mute:0 volumes:2,0.058881,0.058881
alsa_card.pci-0000:00:1f.3:input:analog-input-mic mute:0 volumes:2,0.251181,0.251181
alsa_card.pci-0000:00:1f.3:output:analog-output-headphones mute:0 volumes:2,0.354815,0.354815

Changing all the mute:0 to mute:1 doesn’t do the trick either, only masking the systemd units work at this point.
It solves my issue for now but it doesn’t feel like a solid solution in the long run.

Yeah, that’s what I thought too, but was told otherwise.

On KDE, I just have pipewire though, the state of the muted/unmuted stays after reboot so I assumed it was the same on xfce.

Why not just TRY pipewire instead?
What confuses me is that you have pipewire installed. I thought that only would happen on new installs OR if you manually installed it. :person_shrugging:
If you use the package manjaro-pipewire it removes pulse and installs pipe.

There is also a package called manjaro-pulse witch I assume does it in the opposite direction.

So disabling pipewire systemd units kinda solved my issue and your suggestion is to try pipewire :crazy_face: I may be crazy enough to actually do that.

I didn’t install pipewire, I installed obs-studio, pipewire is a dependency.

:person_facepalming:

And yes, I’m almost sure the issue of “mute not staying” would have been solved if you installed manjaro-pipewire

FYI, screencapture with pipewire does not work with OBS in the repos anyway, you need the flatpak for that.
Have fun setting up sinks and whatnot for the output with pulse btw.
I preferred to just click “capture application sound (pipewire)” and be done. xD

pipewire-media-session is the deprecated pipewire session manager. Pipewire users are recommended to use wireplumber instead. pipewire-media-session provides a systemd unit pipewire-media-session.service that might cause a problem with setting microphone mute state but I have never had this package installed to confirm this

I have also never had pipewire-audio installed. This package has systemd unit filter-chain.service that might cause a problem with microphone mute state

Both of those packages could probably be removed

But pipewire-jack cannot be removed. obs-studio requires at least one JACK package installed, so pipewire-jack must be replaced by jack2 to keep obs-studio dependencies satisfied
pipewire-jack does not have a systemd unit, but AFAIK it is always running in the background and might cause issues with PulseAudio

I have never had pipewire-jack installed because I have been using ‘jack’ and ‘jack2’ to produce live audio content for many years

screencapture with pipewire does not work with OBS in the repos anyway

I have used obs-studio from extra repository to mix audio from ALSA, PulseAudio and JACK
and never had a problem with audio or screen capture on Xfce
(not including user error and misconfigurations )

Also never needed any FlatHats because AUR rocks!

Well, removing pipewire-audio or pipewire-jack would break my System.

test remove pipewire-audio
timer                        2.0.0.r2.g46992c8-1               -0.10 MiB
viber                        21.0.0.1-2                      -522.47 MiB
vinagre                      1:3.22.0+r160+gc86e114-1          -4.62 MiB
vlc                          3.0.20-2                         -59.96 MiB
vulkan-extra-tools           1.3.250.0-1                       -1.76 MiB
whalebird-bin                5.1.1-2                         -143.70 MiB
wireshark-qt                 4.2.0-2                           -9.29 MiB
xfce4-volumed-pulse          0.2.4-1                           -0.03 MiB
pipewire-audio               1:1.0.0-2                         -4.63 MiB

GesamtgrĂ¶ĂŸe der entfernten Pakete:  6007.73 MiB

:: Möchten Sie diese Pakete entfernen? [J/n] 

[edit] ah, I see you using PulseAudio instead

If a user uninstalls either jack2 or pipewire-jack imitation service, package manger will also request removal of any packages that require jack as a dependency

But pipewire-jack is not tied in with dependencies to other pipewire packages
so even pipewire-pulse users can replace pipewire-jack with jack2

pamac install jack2

I think my issue is solved. I installed manjaro-pipewire and therefore removed pulseaudio, never a good idea to have 2 packages installed that can interfere with each other.
All audio function seam to work as I use them and my microphone keeps muted at startup.
It took me a while to get pipewire working but as soon as I remembered I had some systemd unit masked from my previous attempts to debug I had audio again :rofl:.
If I run into issues with pipewire I’ll open a new thread. Thanks all for your help and suggestions.

1 Like

So I was correct the whole time?

Maybe now would be a GREAT time to say “Thank you and sorry for me acting out Bedna!”

You are welcome.
Merry xmas. :christmas_tree:

Original question was about PulseAudio and suggestion in post #7 was verified on an Xfce system with pulseaudio; libpipewire and pipewire installed

Having 3 or more PipeWire packages that could interfere with PulseAudio would be trickier to work out than reverting to PipeWire

But if you have all audio working it doesn’t really matter how you get there if you can turn it up and party on!

Lang may yer lum reek, slĂ inte mhath

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.