mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Simplify the audio input muting
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
Executable
+14
@@ -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
|
||||
Reference in New Issue
Block a user