aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-04-22 18:28:49 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2019-04-22 18:28:49 +0200
commit7877ae71cb890fb458afa68b71e9ba10abf52392 (patch)
treeca42e4ef5186ca18b5c5fae15e02dad545963087
parentbe6588796a2b1f158357c26ca271af4d375b1e86 (diff)
downloadscripts-7877ae71cb890fb458afa68b71e9ba10abf52392.tar.gz
scripts-7877ae71cb890fb458afa68b71e9ba10abf52392.zip
Created scripts to handle mail.
-rwxr-xr-xi3blocks/mailbox.sh20
-rwxr-xr-xmail.sh9
-rwxr-xr-xsyncMail.sh10
3 files changed, 39 insertions, 0 deletions
diff --git a/i3blocks/mailbox.sh b/i3blocks/mailbox.sh
new file mode 100755
index 0000000..89fb49a
--- /dev/null
+++ b/i3blocks/mailbox.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# i3blocks mail module.
+# Displays number of unread mail and an loading icon if updating.
+# When clicked, brings up `neomutt`.
+
+case $BLOCK_BUTTON in
+ 1) "$TERMINAL" -e mail.sh ;;
+ 2) setsid "$HOME/scripts/floats/urxvtFloat.sh" 66 3 syncMail.sh >/dev/null & ;;
+ 3) pgrep -x dunst >/dev/null && dunstify "📬 Mail module" "\- Shows unread mail
+- Shows 🔃 if syncing mail
+- Left click opens neomutt
+- Middle click syncs mail" ;;
+esac
+
+gmailN="$(du -a ~/.mail/gmail/INBOX/new/* 2>/dev/null | sed -n '$=')"
+[ "$gmailN" ] || gmailN="0"
+unioviN="$(du -a ~/.mail/uniovi/INBOX/new/* 2>/dev/null | sed -n '$=')"
+[ "$unioviN" ] || unioviN="0"
+echo "$(cat /tmp/imapsyncicon) Gmail: $gmailN uniovi: $unioviN"
diff --git a/mail.sh b/mail.sh
new file mode 100755
index 0000000..7798354
--- /dev/null
+++ b/mail.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Opens a mailbox using neomutt (and isync if neomutt configured to do so)
+
+pkill -SIGRTMIN+15 i3blocks
+account="$(printf "gmail\nuniovi" | fzf)"
+[ "$account" = "gmail" ] && neomutt -F "$HOME/.config/mutt/gmmuttrc"
+[ "$account" = "uniovi" ] && neomutt -F "$HOME/.config/mutt/cumuttrc"
+pkill -SIGRTMIN+15 i3blocks
diff --git a/syncMail.sh b/syncMail.sh
new file mode 100755
index 0000000..ecaa05a
--- /dev/null
+++ b/syncMail.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Calls mbsync (isync binary) to syncronize mailboxes
+
+echo "🔃" > /tmp/imapsyncicon
+pkill -SIGRTMIN+15 i3blocks
+mbsync -c ~/.config/isync/gmmbsyncrc -a
+mbsync -c ~/.config/isync/uombsyncrc -a
+rm /tmp/imapsyncicon
+pkill -SIGRTMIN+15 i3blocks