------------------------------------------------------------------------------- Microphone Auto Switch When headhones are plugged in the output switches atomatically to them But the microphone does not, and needs to be manually switched! ------------------------------------------------------------------------------- PusleAudio Configuration Change https://bugs.freedesktop.org/show_bug.cgi?id=101798#c5 Add the following to /usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf =======8<-------- [Jack Headphone Mic] state.plugged = no state.unplugged = unknown [Jack Headset Mic] state.plugged = no state.unplugged = unknown =======8<-------- This basically makes the internal mic 'unknown' while a headset is plugged in so it switches to the next available mic, on the headset This WORKS, but may get overwritten on pulse audio updates ------------------------------------------------------------------------------- Using a acpid daemon https://askubuntu.com/questions/1098683/ acpi_listen # watch devices being pluged in and out Pulseaudio is what can swicth the values # Set headphone microphone pacmd set-source-port alsa_input.pci-0000_00_1f.3.analog-stereo \ analog-input-headset-mic # Set back to internal microphone pacmd set-source-port alsa_input.pci-0000_00_1f.3.analog-stereo \ analog-input-internal-mic Create a script to auto swicth between them on plugin This has to be adjusted to suit. echo ' # append ports to a firewall config file | #!/bin/sh | # | # switch between microphones | # | export PULSE_RUNTIME_PATH="/run/user/1000/pulse/" | sudo -u you -E pacmd set-source-port \ | alsa_input.pci-0000_00_1f.3.analog-stereo \ | analog-input-"${1@Q}"-mic | ' perl -ne 's/\s*#.*$//; s/^\s*\| // && print' \ > /etc/acpi/actions/headset-microphone.sh Create a listener files to do the switch according to the acpi_listen echo ' | event=jack/headphone HEADPHONE plug | action=/etc/acpi/actions/headset-microphone.sh headset ' perl -ne 's/\s*#.*$//; s/^\s*\| // && print' \ > /etc/acpi/events/headset-microphone-plug echo ' | event=jack/headphone HEADPHONE unplug | action=/etc/acpi/actions/headset-microphone.sh internal ' perl -ne 's/\s*#.*$//; s/^\s*\| // && print' \ > /etc/acpi/events/headset-microphone-unplug Enable Additions systemctl restart acpid.service ------------------------------------------------------------------------------- Using a acpid daemon Alternative - one event file https://bbs.archlinux.org/viewtopic.php?id=215248 This script not only adjusts the headset, but determined the user involved. echo ' # append ports to a firewall config file | #!/bin/sh | # | # swicth between microphones | # | [ "$1" = jack/headphone ] && [ "$2" = HEADPHONE ] || exit 0 | | SRC="alsa_input.pci-0000_00_1f.3.analog-stereo" | SINK="alsa_output.pci-0000_00_1f.3.analog-stereo" | | case "$3" in | unplug) SRCE_DEV="analog-input-internal-mic" | SINK_DEV="analog-output-speaker" | ;; | plug) SRCE_DEV="analog-input-headset-mic" | SINK_DEV="analog-output-headphones" | ;; | esac | | USERS="$(ps axc -o command,user | sed -n 's/^pulseaudio *//p' | sort -u)" | | for user in $USERS; do | export PULSE_RUNTIME_PATH="/run/user/$id -u $user)/pulse/" | su $user -c "pacmd set-sink-port $SINK $SINK_DEV" | su $user -c "pacmd set-source-port $SRCE $SRCE_DEV" | done | ' perl -ne 's/\s*#.*$//; s/^\s*\| // && print' \ > /etc/acpi/actions/headset-jack.sh echo ' | event=jack/headphone | action=/etc/acpi/actions/headset-jack.sh %e ' perl -ne 's/\s*#.*$//; s/^\s*\| // && print' \ > /etc/acpi/events/headset-microphone systemctl restart acpid.service -------------------------------------------------------------------------------