diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-11-04 23:01:55 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-11-04 23:01:55 +0100 |
commit | 7b68345ead9a3f5030a5aeb7eeb2d54b9a367191 (patch) | |
tree | 4baa41612157e017ba49c1314100e1bf04d57d6c /.config/eww/scripts/email-listener | |
parent | 54a957bf5b27d0d8bc73365b5f3509bff9963bda (diff) |
notify: Add the notify script
Diffstat (limited to '.config/eww/scripts/email-listener')
-rwxr-xr-x | .config/eww/scripts/email-listener | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/.config/eww/scripts/email-listener b/.config/eww/scripts/email-listener index c676676..861bf28 100755 --- a/.config/eww/scripts/email-listener +++ b/.config/eww/scripts/email-listener @@ -1,5 +1,8 @@ #!/bin/sh +readonly CACHE="${XDG_CACHE_HOME:=$HOME/.cache}/email-listener" +touch "$CACHE" + count() { local cur=`find "$MAILDIR"/*/Inbox/cur -type f | wc -l` @@ -20,26 +23,30 @@ count() [ $new -gt 0 ] && printf ' (%d Unread)' $new echo - new_mails=$new + echo $new >"$CACHE" } { while sleep 1 do - if [ ${new_mails:=0} -gt ${prev:=0} ] + read new_mails <"$CACHE" + if [ $new_mails -gt ${prev:=0} ] then - case $new_mails in + local title + local desc + + case $((new_mails - prev)) in 1) - local title='New Email' - local desc='1 new email has been received.' + title='New Email' + desc='1 new email has been received' ;; *) - local title='New Emails' - local desc="$new_mails new emails have been received." + title='New Emails' + desc="$new_mails new emails have been received" ;; esac - notify-send -a email "$title" "$desc" + notify email email "$title" "$desc" prev=$new_mails fi done |