#!/bin/bash MAILDIR=$HOME/.mail ACCOUNTS=(posteo gmail xkonni) SERVICES=(mbsync@ykonni muchsync@ykonni) text="" tooltip="accounts\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+="\nservices\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