From 1746a86a7b1acecfde4bbecbab4f0587b586a93a Mon Sep 17 00:00:00 2001 From: Spencer Bull Date: Fri, 10 Apr 2026 05:35:41 -0500 Subject: [PATCH] Enable Dell XPS Mute Mic Key (#5252) * If on XPS, enable XPS mute mic key with LED and fallback to original mic mute flow * fix hardcode of alsa card 0 to resolved id * Extract omarchy-hyprland-monitor-focused * Extract dedicated xps mute script --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-cmd-audio-switch | 2 +- bin/omarchy-cmd-mic-mute | 9 ++++++ bin/omarchy-cmd-mic-mute-xps | 44 ++++++++++++++++++++++++++++ bin/omarchy-hyprland-monitor-focused | 5 ++++ bin/omarchy-launch-screensaver | 3 +- bin/omarchy-swayosd-brightness | 2 +- bin/omarchy-swayosd-kbd-brightness | 2 +- default/hypr/bindings/media.conf | 4 +-- 8 files changed, 64 insertions(+), 7 deletions(-) create mode 100755 bin/omarchy-cmd-mic-mute create mode 100755 bin/omarchy-cmd-mic-mute-xps create mode 100755 bin/omarchy-hyprland-monitor-focused diff --git a/bin/omarchy-cmd-audio-switch b/bin/omarchy-cmd-audio-switch index 1cb51086..de81cc3f 100755 --- a/bin/omarchy-cmd-audio-switch +++ b/bin/omarchy-cmd-audio-switch @@ -2,7 +2,7 @@ # Switch between audio outputs while preserving the mute status. By default mapped to Super + Mute. -focused_monitor="$(hyprctl monitors -j | jq -r '.[] | select(.focused == true).name')" +focused_monitor=$(omarchy-hyprland-monitor-focused) sinks=$(pactl -f json list sinks | jq '[.[] | select((.ports | length == 0) or ([.ports[]? | .availability != "not available"] | any))]') sinks_count=$(echo "$sinks" | jq '. | length') diff --git a/bin/omarchy-cmd-mic-mute b/bin/omarchy-cmd-mic-mute new file mode 100755 index 00000000..7f10fa94 --- /dev/null +++ b/bin/omarchy-cmd-mic-mute @@ -0,0 +1,9 @@ +#!/bin/bash + +# Toggle microphone mute. Dell XPS systems get special handling for the hardware LED. + +if omarchy-hw-match "XPS"; then + omarchy-cmd-mic-mute-xps +else + swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" --input-volume mute-toggle +fi diff --git a/bin/omarchy-cmd-mic-mute-xps b/bin/omarchy-cmd-mic-mute-xps new file mode 100755 index 00000000..8e7ca135 --- /dev/null +++ b/bin/omarchy-cmd-mic-mute-xps @@ -0,0 +1,44 @@ +#!/bin/bash + +# Toggle microphone mute on Dell XPS systems. Uses wpctl for reliable toggling +# and syncs the ALSA capture switch so the hardware mic mute LED follows state. + +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 + +swayosd-client \ + --monitor "$(omarchy-hyprland-monitor-focused)" \ + --custom-message "$osd_message" \ + --custom-icon "$osd_icon" diff --git a/bin/omarchy-hyprland-monitor-focused b/bin/omarchy-hyprland-monitor-focused new file mode 100755 index 00000000..2b4b8eea --- /dev/null +++ b/bin/omarchy-hyprland-monitor-focused @@ -0,0 +1,5 @@ +#!/bin/bash + +# Print the name of the currently focused Hyprland monitor. + +hyprctl monitors -j | jq -r '.[] | select(.focused == true).name' diff --git a/bin/omarchy-launch-screensaver b/bin/omarchy-launch-screensaver index 03d1159a..7ce8d54e 100755 --- a/bin/omarchy-launch-screensaver +++ b/bin/omarchy-launch-screensaver @@ -18,7 +18,6 @@ fi # Silently quit Walker on overlay walker -q -focused=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true).name') terminal=$(xdg-terminal-exec --print-id) for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do @@ -51,4 +50,4 @@ for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do esac done -hyprctl dispatch focusmonitor $focused +hyprctl dispatch focusmonitor $(omarchy-hyprland-monitor-focused) diff --git a/bin/omarchy-swayosd-brightness b/bin/omarchy-swayosd-brightness index 1fb492a1..0dbe44d2 100755 --- a/bin/omarchy-swayosd-brightness +++ b/bin/omarchy-swayosd-brightness @@ -9,7 +9,7 @@ progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" [[ $progress == "0.00" ]] && progress="0.01" swayosd-client \ - --monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \ + --monitor "$(omarchy-hyprland-monitor-focused)" \ --custom-icon display-brightness \ --custom-progress "$progress" \ --custom-progress-text "${percent}%" diff --git a/bin/omarchy-swayosd-kbd-brightness b/bin/omarchy-swayosd-kbd-brightness index 4c0a30bb..bf51d749 100755 --- a/bin/omarchy-swayosd-kbd-brightness +++ b/bin/omarchy-swayosd-kbd-brightness @@ -9,7 +9,7 @@ progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" [[ $progress == "0.00" ]] && progress="0.01" swayosd-client \ - --monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \ + --monitor "$(omarchy-hyprland-monitor-focused)" \ --custom-icon keyboard-brightness \ --custom-progress "$progress" \ --custom-progress-text "${percent}%" diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index 9506ff41..88763037 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -1,11 +1,11 @@ # Only display the OSD on the currently focused monitor -$osdclient = swayosd-client --monitor "$(hyprctl monitors -j | jq -r '.[] | select(.focused == true).name')" +$osdclient = swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" # Laptop multimedia keys for volume and LCD brightness (with OSD) bindeld = ,XF86AudioRaiseVolume, Volume up, exec, $osdclient --output-volume raise bindeld = ,XF86AudioLowerVolume, Volume down, exec, $osdclient --output-volume lower bindeld = ,XF86AudioMute, Mute, exec, $osdclient --output-volume mute-toggle -bindeld = ,XF86AudioMicMute, Mute microphone, exec, $osdclient --input-volume mute-toggle +bindeld = ,XF86AudioMicMute, Mute microphone, exec, omarchy-cmd-mic-mute bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display +5% bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-display 5%- bindeld = ,XF86KbdBrightnessUp, Keyboard brightness up, exec, omarchy-brightness-keyboard up