[mail] fix: check new-ness against $timestamp
This commit is contained in:
parent
e29723ec26
commit
a17e7fc134
@ -13,6 +13,8 @@
|
||||
# and the GPG home. This is done by searching common profile files for variable
|
||||
# assignments.
|
||||
|
||||
timestamp="${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun"
|
||||
|
||||
eval "$(grep -h -- \
|
||||
"^\s*\(export \)\?\(XDG_CACHE_HOME\|XDG_CONFIG_HOME\|XDG_DATA_HOME\)=" \
|
||||
"$HOME/.zshenv" 2>/dev/null)"
|
||||
@ -37,7 +39,7 @@ notify() {
|
||||
syncandnotify() {
|
||||
acc="$(echo "$account" | sed "s/.*\///")"
|
||||
mbsync "$acc"
|
||||
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" 2>/dev/null)"
|
||||
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f -newer "$timestamp" | grep -iv -e "trash" -e "drafts" 2>/dev/null)"
|
||||
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
|
||||
if [ "$newcount" -gt "0" ]; then
|
||||
notify "$acc" "$newcount" &
|
||||
@ -57,4 +59,4 @@ wait
|
||||
notmuch new 2>/dev/null
|
||||
|
||||
#Create a touch file that indicates the time of the last run of mailsync
|
||||
touch "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun"
|
||||
touch $timestamp
|
||||
|
Reference in New Issue
Block a user