Simplify the audio input muting

This commit is contained in:
David Heinemeier Hansson
2026-05-02 10:24:31 +02:00
parent bdd8de0501
commit 241145f85b
4 changed files with 30 additions and 69 deletions
+16 -6
View File
@@ -1,11 +1,21 @@
#!/bin/bash #!/bin/bash
# omarchy:summary=Toggle microphone mute. Dell XPS and ThinkPad systems get special handling for the hardware LED. # omarchy:summary=Toggle microphone mute. Drives the hardware mic-mute LED on laptops that expose one.
if omarchy-hw-match "XPS"; then wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null
omarchy-audio-input-mute-xps
elif omarchy-hw-match "ThinkPad"; then if pactl get-source-mute @DEFAULT_SOURCE@ | rg -q 'yes'; then
omarchy-audio-input-mute-thinkpad led=on
osd_message='Microphone muted'
osd_icon='microphone-sensitivity-muted-symbolic'
else else
omarchy-swayosd-client --input-volume mute-toggle led=off
osd_message='Microphone on'
osd_icon='audio-input-microphone-symbolic'
fi fi
omarchy-brightness-keyboard-mute "$led"
omarchy-swayosd-client \
--custom-message "$osd_message" \
--custom-icon "$osd_icon"
-21
View File
@@ -1,21 +0,0 @@
#!/bin/bash
# omarchy:summary=Toggle microphone mute on ThinkPad systems. Uses wpctl for reliable toggling
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null
if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q 'yes'; then
osd_message='Microphone muted'
osd_icon='microphone-sensitivity-muted-symbolic'
led_value=1
else
osd_message='Microphone on'
osd_icon='audio-input-microphone-symbolic'
led_value=0
fi
brightnessctl --device="platform::micmute" set "$led_value" >/dev/null 2>&1 || true
omarchy-swayosd-client \
--custom-message "$osd_message" \
--custom-icon "$osd_icon"
-42
View File
@@ -1,42 +0,0 @@
#!/bin/bash
# omarchy:summary=Toggle microphone mute on Dell XPS systems. Uses wpctl for reliable toggling
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null
if pactl get-source-mute @DEFAULT_SOURCE@ | rg -q 'yes'; then
alsa_value='off,off'
osd_message='Microphone muted'
osd_icon='microphone-sensitivity-muted-symbolic'
else
alsa_value='on,on'
osd_message='Microphone on'
osd_icon='audio-input-microphone-symbolic'
fi
if [[ -e /sys/class/leds/platform::micmute/brightness ]]; then
default_source=$(pactl get-default-source)
alsa_card=$(pactl -f json list sources | jq -r --arg source "$default_source" '
.[] | select(.name == $source) |
.properties["alsa.card"] // .properties["api.alsa.card"] // .properties["api.alsa.pcm.card"] // empty
' | head -1)
if [[ -n $alsa_card ]]; then
cards=("$alsa_card")
else
mapfile -t cards < <(compgen -G '/proc/asound/card*' | rg -o 'card[0-9]+' | sed 's/card//' | sort -u)
fi
for card in "${cards[@]}"; do
while IFS= read -r control; do
if [[ $control != *"Jack Microphone"* ]]; then
amixer -c "$card" cset "$control" "$alsa_value" >/dev/null 2>&1 || true
break 2
fi
done < <(amixer -c "$card" controls 2>/dev/null | rg -o "name='[^']*Microphone Capture Switch'")
done
fi
omarchy-swayosd-client \
--custom-message "$osd_message" \
--custom-icon "$osd_icon"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# omarchy:summary=Set the mic-mute indicator LED on laptops that expose a platform::micmute LED node.
# omarchy:args=<on|off>
if [[ -e /sys/class/leds/platform::micmute/brightness ]]; then
case "$1" in
on) value=1 ;;
off) value=0 ;;
*) echo "Usage: $(basename "$0") <on|off>" >&2; exit 1 ;;
esac
brightnessctl --device="platform::micmute" set "$value" >/dev/null 2>&1 || true
fi