initial commit master
authorJacob Casper <dev@jacobcasper.com>
Sun, 6 Jun 2021 18:38:36 +0000 (13:38 -0500)
committerJacob Casper <dev@jacobcasper.com>
Sun, 6 Jun 2021 18:38:36 +0000 (13:38 -0500)
README.md [new file with mode: 0644]
mail-count.service [new file with mode: 0644]
mail-count.timer [new file with mode: 0644]
setup.sh [new file with mode: 0755]
unread_mail_counts.sh [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
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 (file)
index 0000000..afa12b9
--- /dev/null
@@ -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 (file)
index 0000000..deaa659
--- /dev/null
@@ -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 (executable)
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 (executable)
index 0000000..7b700ad
--- /dev/null
@@ -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