This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/apps/de/polybar/mic.sh

37 lines
488 B
Bash
Raw Normal View History

2020-01-20 14:01:06 -06:00
#!/usr/bin/env sh
2020-01-23 12:38:19 -06:00
pidfile="/var/run/user/$(id -u)/polybar-mic-script.sh.pid"
if [ -e "$pidfile" ]; then
kill "$(cat "${pidfile}")" > /dev/null 2>&1
cleanup
fi
cleanup() {
rm -f "$pidfile"
}
print_status() {
if amixer get Capture | grep -q '\[off\]'; then
echo ""
else
echo " "
fi
}
toggle() {
amixer set Capture toggle > /dev/null 2>&1
print_status
}
trap "cleanup" EXIT
trap "toggle" USR1
echo $$ > "$pidfile"
while true; do
print_status
sleep 1 &
wait
done