swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

sb-mailbox (752B)


      1 #!/bin/sh
      2 
      3 # Displays number of unread mail and an loading icon if updating.
      4 # When clicked, brings up `neomutt`.
      5 
      6 case $BLOCK_BUTTON in
      7   1) setsid -w -f "$TERMINAL" -e neomutt ; pkill -RTMIN+12 "${STATUSBAR:-i3blocks}" ;;
      8   2) setsid -f mailup >/dev/null && exit ;;
      9   3) notify-send "📬 Mail module" "\- Shows unread mail
     10 - Shows 🔃 if syncing mail
     11 - Left click opens neomutt
     12 - Middle click syncs mail" ;;
     13   8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;;
     14 esac
     15 
     16 unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
     17 
     18 icon=$(cat /tmp/mailupdate 2>/dev/null)
     19 
     20 if [ "$unread" -eq 0 ]; then
     21   [ -n "$icon" ] && echo "📬$icon" || exit 0
     22 else
     23   echo "📬$unread$icon"
     24 fi