summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2026-04-20 13:32:33 +0500
committerAnton Bobov <anton@bobov.name>2026-07-24 14:21:46 +0500
commitf8ee0b083ea75630845a8fbe6662de2e97fa09a3 (patch)
treeb1530b0b03c5f788629ae80316f78e8788ab95d1
parent1de46b8a4ad776d1e429785d99a199572db441a1 (diff)
mic-toggle: add 1-hour mic-on reminder and manage pw-loopback process
-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
}