From: Jacob Casper Date: Sun, 6 Jun 2021 18:38:36 +0000 (-0500) Subject: initial commit X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;ds=inline;p=mail-count.git initial commit --- 9fc22a765d89605eb4eaacff42ead55acc11589f diff --git a/README.md b/README.md new file mode 100644 index 0000000..94dd710 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Install +`sudo setup.sh` +Make your Maildir read/writeable by `mailcount` group +# Uninstall +`sudo rm /usr/local/bin/mailcount` diff --git a/mail-count.service b/mail-count.service new file mode 100644 index 0000000..afa12b9 --- /dev/null +++ b/mail-count.service @@ -0,0 +1,13 @@ +[Unit] +Description=Mailbox Count and Sync Service +After=network.target mail-count.timer +Requires=mail-count.timer + +[Service] +Type=oneshot +User=mailcount +Group=mailcount +ExecStart=/usr/bin/bash -c "/usr/bin/dbus-send --type=method_call --session --dest=com.jacobcasper.Mail /com/jacobcasper/Mail/Unread com.jacobcasper.Mail.UnreadCount uint32:$(/usr/local/bin/mailcount)" + +[Install] +WantedBy=multi-user.target diff --git a/mail-count.timer b/mail-count.timer new file mode 100644 index 0000000..deaa659 --- /dev/null +++ b/mail-count.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Mailbox Sync and Count Timer +After=network.target + +[Timer] +OnActiveSec=1s +OnUnitActiveSec=5m +Unit=mail-count.service + +[Install] +WantedBy=multi-user.target diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..e7d8107 --- /dev/null +++ b/setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +mkdir -p /usr/share/mailcount +groupadd mailcount +useradd -g mailcount -d /usr/share/mailcount -s $(which nologin) mailcount +chown mailcount:mailcount /usr/share/mailcount +chmod 700 /usr/share/mailcount +cp mail-count.* /etc/systemd/system/ +ln -f unread_mail_counts.sh /usr/local/bin/mailcount diff --git a/unread_mail_counts.sh b/unread_mail_counts.sh new file mode 100755 index 0000000..7b700ad --- /dev/null +++ b/unread_mail_counts.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Shouldn't require any GNU utils, but not 100% on that negative lookahead flag +mbsync -c /home/jcasper/.mbsyncrc -aq +find /home/jcasper/mail/INBOX/ -type f -not -path '*/\.*' -print \ + | grep -P '.*U=.*:2,(?!.*S)' \ + | wc -l