#!/usr/bin/env bash 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 } main