waybar: add service status to mail

This commit is contained in:
Konstantin Koslowski 2021-05-14 22:39:50 +02:00
parent 711c9a31f9
commit c3035cb45e

View file

@ -2,17 +2,24 @@
MAILDIR=$HOME/.mail
ACCOUNTS=(posteo gmail xkonni)
SERVICES=(mbsync@ykonni muchsync@ykonni)
text=""
tooltip=""
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"
[ ! $acc = ${ACCOUNTS[-1]} ] && tooltip+="\n"
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\"}"