This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/scripts/checkmail

28 lines
477 B
Bash
Executable file

#!/bin/sh
set -e
test -z "$XDG_RUNTIME_DIR" &&
export XDG_RUNTIME_DIR=/run/user/$(id -u)
getnew(){
find ~/.local/share/mail/INBOX{,.{Contas,Faculdade,Git,Trabalhos}}/new -type f | wc -l
}
OLD=$(getnew)
[ "$1" = "update" ] && mbsync -a
NEW=$(getnew)
if [ "$NEW" -gt "$OLD" ];then
notify-send " New E-Mails!"
fi
echo $NEW | sed 's/^0$//'
if [ "$(ps -o comm= $PPID)" != "waybar" ] && pidof waybar>/dev/null;then
pkill -SIGRTMIN+4 waybar
fi
# vim:ft=sh