From 241145f85bf16d05f9c2a58079e30cd85d1bc56d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 2 May 2026 10:24:31 +0200 Subject: [PATCH] Simplify the audio input muting --- bin/omarchy-audio-input-mute | 22 ++++++++++---- bin/omarchy-audio-input-mute-thinkpad | 21 -------------- bin/omarchy-audio-input-mute-xps | 42 --------------------------- bin/omarchy-brightness-keyboard-mute | 14 +++++++++ 4 files changed, 30 insertions(+), 69 deletions(-) delete mode 100755 bin/omarchy-audio-input-mute-thinkpad delete mode 100755 bin/omarchy-audio-input-mute-xps create mode 100755 bin/omarchy-brightness-keyboard-mute diff --git a/bin/omarchy-audio-input-mute b/bin/omarchy-audio-input-mute index c0ab990c..19e12f23 100755 --- a/bin/omarchy-audio-input-mute +++ b/bin/omarchy-audio-input-mute @@ -1,11 +1,21 @@ #!/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 - omarchy-audio-input-mute-xps -elif omarchy-hw-match "ThinkPad"; then - omarchy-audio-input-mute-thinkpad +wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null + +if pactl get-source-mute @DEFAULT_SOURCE@ | rg -q 'yes'; then + led=on + osd_message='Microphone muted' + osd_icon='microphone-sensitivity-muted-symbolic' else - omarchy-swayosd-client --input-volume mute-toggle + led=off + osd_message='Microphone on' + osd_icon='audio-input-microphone-symbolic' fi + +omarchy-brightness-keyboard-mute "$led" + +omarchy-swayosd-client \ + --custom-message "$osd_message" \ + --custom-icon "$osd_icon" diff --git a/bin/omarchy-audio-input-mute-thinkpad b/bin/omarchy-audio-input-mute-thinkpad deleted file mode 100755 index d06c4cf6..00000000 --- a/bin/omarchy-audio-input-mute-thinkpad +++ /dev/null @@ -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" diff --git a/bin/omarchy-audio-input-mute-xps b/bin/omarchy-audio-input-mute-xps deleted file mode 100755 index 85d1cbb5..00000000 --- a/bin/omarchy-audio-input-mute-xps +++ /dev/null @@ -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" diff --git a/bin/omarchy-brightness-keyboard-mute b/bin/omarchy-brightness-keyboard-mute new file mode 100755 index 00000000..65f73264 --- /dev/null +++ b/bin/omarchy-brightness-keyboard-mute @@ -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= + +if [[ -e /sys/class/leds/platform::micmute/brightness ]]; then + case "$1" in + on) value=1 ;; + off) value=0 ;; + *) echo "Usage: $(basename "$0") " >&2; exit 1 ;; + esac + + brightnessctl --device="platform::micmute" set "$value" >/dev/null 2>&1 || true +fi