#!/bin/sh
set -eu

while true; do
  printf "mail: %s/%s - %s\n" "$(notmuch count tag:unread AND \(tag:to-me OR to:nubank.com.br OR to:euandre.org\) AND NOT tag:killed AND NOT tag:archive)" "$(notmuch count tag:inbox AND \(tag:to-me OR to:nubank.com.br OR to:euandre.org\) AND NOT tag:killed AND NOT tag:archive)" "$(msmtp-queue -d | grep -c '^From')"
  if acpi -a | grep -q off-line; then
    sleep $((60 * 15))
  else
    sleep $((60 * 1))
  fi
done
