浏览代码

exclude folders that we do not want notifactions for

exclude drafts, sent, trash etc from search for new mail.  I still
believe it's usefull to have a notification for all the folders
except these.
pull/455/head
rjl6789 4 年前
父节点
当前提交
fa436774b0
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. +5
    -2
      bin/mailsync

+ 5
- 2
bin/mailsync 查看文件

@@ -1,7 +1,10 @@
#!/bin/sh

# Sync mail and give notification if there is new mail.

MAILDIR="$HOME/.local/share/mail"
SYNCSTAT="$HOME/.config/mutt/.mailsynclastrun"
# Sync mail and give notification if there is new mail.
FOLDEREXCLUDES='sent|drafts|bin|trash|spam|junk'

# Run only if user logged in (prevent cron errors)
pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;}
@@ -32,7 +35,7 @@ fi
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi
folderlist="$(find "$MAILDIR"/"$acc"/*/new -type d 2>/dev/null | sed '/^\s*$/d')"
folderlist="$(find "$MAILDIR"/"$acc"/*/new -type d 2>/dev/null | sed '/^\s*$/d' | awk -v exclude=$FOLDEREXCLUDES 'BEGIN {IGNORECASE = 1} $0 !~ exclude')"
for folder in $folderlist; do
new="$(find "$folder" -type f -newer "$SYNCSTAT" 2> /dev/null)"
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)


正在加载...
取消
保存