summaryrefslogtreecommitdiff
path: root/sb-mailbox
diff options
context:
space:
mode:
Diffstat (limited to 'sb-mailbox')
-rwxr-xr-xsb-mailbox24
1 files changed, 24 insertions, 0 deletions
diff --git a/sb-mailbox b/sb-mailbox
new file mode 100755
index 0000000..19478e8
--- /dev/null
+++ b/sb-mailbox
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Displays number of unread mail and an loading icon if updating.
+# When clicked, brings up `neomutt`.
+
+case $BLOCK_BUTTON in
+ 1) setsid -w -f "$TERMINAL" -e neomutt ; pkill -RTMIN+12 "${STATUSBAR:-waybar}" ;;
+ 2) setsid -f mailup >/dev/null && exit ;;
+ 3) notify-send " Mail module" "\- Shows unread mail
+- Shows  if syncing mail
+- Left click opens neomutt
+- Middle click syncs mail" ;;
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;;
+esac
+
+unread="$(fd . "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/ -t f | wc -l 2>/dev/null)"
+
+icon=$(bat /tmp/mailupdate 2>/dev/null)
+
+if [ "$unread" -eq 0 ]; then
+ [ -n "$icon" ] && echo "$icon" || exit 0
+else
+ echo " $unread$icon"
+fi