commit 7d5ac0291469188e5ccba679876726cc970a5da3 parent 8f61cabca2066b6816820a0027badd804aaeaab0 Author: Milutin Popovic <milutin@popovic.xyz> Date: Thu, 9 Apr 2026 09:45:58 +0100 update Diffstat:
| M | .local/bin/scripts/check-mail | | | 12 | +++++------- |
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/.local/bin/scripts/check-mail b/.local/bin/scripts/check-mail @@ -2,14 +2,12 @@ while :; do n_mails=$(find "$XDG_DATA_HOME/mail" -path '*/INBOX/new/*' -type f 2>/dev/null | wc -l) - last_new=$(cat $XDG_CACHE_HOME/status/mail.new) - if [[ $n_mails -gt $last_new ]] - then - notify-send "New Email" "$n_mails new messages" - echo $n_mails > $XDG_CACHE_HOME/status/mail.new + last_new=$(cat "$XDG_CACHE_HOME/status/mail.new" 2>/dev/null || echo 0) - else - echo $n_mails > $XDG_CACHE_HOME/status/mail.new + if [ "$n_mails" -gt "$last_new" ]; then + notify-send "New Email" "$n_mails new messages" fi + + echo "$n_mails" > "$XDG_CACHE_HOME/status/mail.new" sleep 1 done