How to programatically mute a microphone (or capture device/stream) on KDE

Well, title says it all, I am trying to programmatically implement a way to mute the current capture stream/microphone. My first idea was to use dbus messages to KMix, but for some reason, it does not work.

Examples:

i="org.kde.kmix" o="/Mixers/PulseAudio__Capture_Devices_1"
  • with qdbus:
$ dev="$(qdbus "$i" "$o" "org.kde.KMix.Mixer.masterControl")"
$ echo "$dev"
/Mixers/PulseAudio__Capture_Devices_1/alsa_input_usb_SteelSeries_SteelSeries_Arctis_1_Wireless_00_mono_fallback
$ qdbus "$i" "$dev" "org.freedesktop.DBus.Properties.GetAll" "org.kde.KMix.Control"
absoluteVolume: 64881
absoluteVolumeMax: 65536
absoluteVolumeMin: 0
canMute: false
hasCaptureSwitch: true
iconName: audio-card-analog
id: alsa_input.usb-SteelSeries_SteelSeries_Arctis_1_Wireless-00.mono-fallback
mute: false
readableName: SteelSeries Arctis 1
recordSource: true
volume: 99
$ qdbus "$i" "$dev" "org.kde.KMix.Control.canMute"
false

$ qdbus "$i" "$dev" "org.kde.KMix.Control.mute"
false

$ qdbus "$i" "$dev" "org.kde.KMix.Control.mute" "true"

$ qdbus "$i" "$dev" "org.kde.KMix.Control.mute"
false
  • with busctl
$ busctl --verbose --user get-property "$i" "$dev" "org.kde.KMix.Control" "canMute"
BOOLEAN false;[/code]

$ busctl --verbose --user get-property "$i" "$dev" "org.kde.KMix.Control" "mute"
BOOLEAN false;

$ busctl --verbose --user set-property "$i" "$dev" "org.kde.KMix.Control" "mute" b "true"
$ busctl --verbose --user get-property "$i" "$dev" "org.kde.KMix.Control" "mute"
BOOLEAN false;

$ busctl --verbose --user call "$i" "$dev" "org.kde.KMix.Control" "toggleMute"
$ busctl --verbose --user get-property "$i" "$dev" "org.kde.KMix.Control" "mute"
BOOLEAN false;
  • with the KMixWindow object:
$ w="/kmix/KMixWindow/actions/mute"

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.text
Mute

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checked
false

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.toggle
$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checked
false

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checkable
false

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checkable true
$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checkable
true

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checked
false

$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checked true
$ qdbus "$i" "$w" org.qtproject.Qt.QAction.checked
true

$ qdbus "$i" "$dev" "org.kde.KMix.Control.mute"
false

nothing seems to work

Any other suggestions to achieve this, please?

Thank you.

For future reference, I ended up using pactl:

pactl set-source-mute @DEFAULT_SOURCE@ 1