config_sway/bin/waybar_mail.sh

26 lines
682 B
Bash
Executable file

#!/bin/bash
MAILDIR=$HOME/.mail
ACCOUNTS=(posteo gmail xkonni)
SERVICES=(mbsync@ykonni muchsync@ykonni)
text=""
tooltip="<b>accounts</b>\n"
total=0
for acc in ${ACCOUNTS[@]}; do
count=$(notmuch count folder:$acc/Inbox AND tag:unread AND NOT tag:killed)
total=$((total+count))
tooltip+=" - $acc: $count\n"
done
tooltip+="\n<b>services</b>\n"
for service in ${SERVICES[@]}; do
tooltip+=" - $service:\n$(systemctl --user status $service | grep -e 'Active' | sed 's/Active:[ ]*//g')\n"
done
alt=$( [ $total -gt 0 ] && echo "unread" || echo "read" )
text="$total"
json="{\"text\": \"$text\", \"tooltip\": \"$tooltip\", \"class\": \"mail\", \"alt\": \"$alt\"}"
echo $json