#!/bin/bash

ID=$1

while true
do
    COMMAND="emacsclient -c -e (mu4e)"

    muunread="$(mu find flag:unread AND NOT flag:trashed AND NOT maildir:\"/outlook/Junk\" AND NOT maildir:\"/office/Junk Email\" AND NOT maildir:\"/outlook/Deleted\" AND NOT maildir:\"/office/Deleted Items\" | wc -l)"

    DATA="| A |   $muunread | |$COMMAND |"
    qdbus org.kde.plasma.doityourselfbar /id_$ID \
          org.kde.plasma.doityourselfbar.pass "$DATA"

    sleep 60s
done
