summaryrefslogtreecommitdiff
path: root/newmail
diff options
context:
space:
mode:
authorTslil Clingman <hiato1@gmail.com>2015-06-24 15:08:32 +0200
committerTslil Clingman <hiato1@gmail.com>2015-06-24 15:08:32 +0200
commitdb8146fe4f86a2d0f76a9e7b4ac392985dafcdc1 (patch)
tree65dde57c2044ef673353cf601e359533a4a69a93 /newmail
parent0100e5ad7197101038dc6c792b1f2c804a43806f (diff)
A more unixy approach
Diffstat (limited to 'newmail')
-rwxr-xr-xnewmail21
1 files changed, 21 insertions, 0 deletions
diff --git a/newmail b/newmail
new file mode 100755
index 0000000..8d298bd
--- /dev/null
+++ b/newmail
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+
+servers="gmail posteo"
+
+result=
+regexp='s#^machine \(.*\) login \(.*\) password \(.*\) port \([0-9]*\)$#-u \2:\3 imaps://\1:\4/INBOX#'
+data=$(gpg --quiet --decrypt $HOME/.authinfo.gpg | grep 993)
+for server in $servers; do
+ line=$(echo "$data" | grep $server | head -n 1)
+ num=$(curl -s --ssl-reqd $(echo $line | sed "$regexp") -X 'SEARCH UNSEEN' | grep SEARCH | wc -w)
+ if [ "$num" != "2" ]; then
+ count=$(($num - 2))
+ if [ -z "$result" ]; then
+ result="$server: $count"
+ else
+ result="$result, $server: $count"
+ fi
+ fi
+done;
+
+echo $result