summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmic-toggle14
1 files changed, 14 insertions, 0 deletions
diff --git a/mic-toggle b/mic-toggle
index f21ba3e..92c0180 100755
--- a/mic-toggle
+++ b/mic-toggle
@@ -3,17 +3,31 @@
set -euo pipefail
JACK_SOURCE=alsa_input.pci-0000_07_00.6.HiFi__hw_Generic_1__source
+ALERT_TIME="1 hour"
+ALERT_QUEUE=m
get_noise_torch_device_name() {
pactl list sources short | grep NoiseTorch | awk -F '\t' '{print $2}' || return 0
}
+cancel_alert() {
+ atq -q "$ALERT_QUEUE" | cut -f 1 | xargs -r atrm
+}
+
+add_alert() {
+ at now + "$ALERT_TIME" -q "$ALERT_QUEUE" <<<"alert 'Toggle mic'" 2>/dev/null
+}
+
main() {
+ cancel_alert
if [ -z "$(get_noise_torch_device_name)" ]; then
noisetorch -i "$JACK_SOURCE"
pactl set-default-source "$(get_noise_torch_device_name)"
+ pw-loopback &
+ add_alert
else
noisetorch -u
+ pkill -x pw-loopback || true
fi
}