summaryrefslogtreecommitdiff
path: root/sb-mailbox
blob: 19478e895cf08ad5ec77c2023b618f979e9adc6b (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
#!/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