aboutsummaryrefslogtreecommitdiff
path: root/i3blocks/i3mailbox.sh
blob: 787885edae366fa8bbf1853af471b105b5c2b8c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

# i3mailbox.sh (i3blocks mail module)
#
# Usage: i3mailbox.sh
#
# 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

label=📫
disrootInbox="$CONFIG_FOLDER_DISROOT_INBOX"
gmailInbox="$CONFIG_FOLDER_GMAIL_INBOX"
unioviInbox="$CONFIG_FOLDER_UNIOVI_INBOX"
output="$label"
shortOutput="$label"
syncIcon=""
[ -n "$(pgrep mbsync)" ] && syncIcon="🔃"
output="$output$syncIcon"
shortOutput="$shortOutput$syncIcon"

if [ -n "$disrootInbox" ]; then
	disrootN="$(ls "$disrootInbox"/* 2>/dev/null | wc -l)"
	output="$output Disroot: $disrootN "
	shortOutput="$shortOutput D: $disrootN "
fi
if [ -n "$gmailInbox" ]; then
	gmailN="$(ls "$gmailInbox"/* 2>/dev/null | wc -l)"
	output="$output Gmail: $gmailN "
	shortOutput="$shortOutput G: $gmailN "
fi
if [ -n "$unioviInbox" ]; then
	unioviN="$(ls "$unioviInbox"/* 2>/dev/null | wc -l)"
	output="$output Uniovi: $unioviN "
	shortOutput="$shortOutput U: $unioviN "
fi

echo "${output% }"
echo "${shortOutput% }"