#!/bin/bash

# archypr:summary=Toggle microphone mute. Drives the hardware mic-mute LED on laptops that expose one.

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
  led=off
  osd_message='Microphone on'
  osd_icon='audio-input-microphone-symbolic'
fi

archypr-rightness-keyboard-mute "$led"

archypr-wayosd-client \
  --custom-message "$osd_message" \
  --custom-icon "$osd_icon"
