New mail notifications
This commit is contained in:
+1
-1
Submodule azos-core updated: 45f3e20522...51e8d56f0c
@@ -31,9 +31,26 @@
|
|||||||
# only queries the card reader (no pinentry involved either way), so it's
|
# only queries the card reader (no pinentry involved either way), so it's
|
||||||
# safe to use as a silent presence check: skip the sync entirely when the
|
# safe to use as a silent presence check: skip the sync entirely when the
|
||||||
# card isn't there, instead of letting mbsync hit that prompt.
|
# card isn't there, instead of letting mbsync hit that prompt.
|
||||||
|
#
|
||||||
|
# New mail is detected by counting files under every account's Maildir
|
||||||
|
# "new" subdirectory before and after the sync -- that's where messages
|
||||||
|
# the server hasn't marked seen land, across all three accounts at once,
|
||||||
|
# with no need to touch mu's index. A rise in that count means mail
|
||||||
|
# actually arrived, so only then does it post a desktop notification via
|
||||||
|
# notify-send -- intentionally separate from mu4e's own "mbsync -a" (its
|
||||||
|
# mu4e-get-mail-command), which doesn't go through this script at all.
|
||||||
mbsyncSafe = pkgs.writeShellScript "mbsync-safe" ''
|
mbsyncSafe = pkgs.writeShellScript "mbsync-safe" ''
|
||||||
if ${pkgs.gnupg}/bin/gpg --card-status >/dev/null 2>&1; then
|
if ! ${pkgs.gnupg}/bin/gpg --card-status >/dev/null 2>&1; then
|
||||||
exec ${pkgs.isync}/bin/mbsync -a
|
exit 0
|
||||||
|
fi
|
||||||
|
before=$(find "$HOME/Maildir" -path '*/new/*' -type f 2>/dev/null | wc -l)
|
||||||
|
${pkgs.isync}/bin/mbsync -a
|
||||||
|
after=$(find "$HOME/Maildir" -path '*/new/*' -type f 2>/dev/null | wc -l)
|
||||||
|
new=$((after - before))
|
||||||
|
if [ "$new" -gt 0 ]; then
|
||||||
|
label="new message"
|
||||||
|
[ "$new" -ne 1 ] && label="new messages"
|
||||||
|
${pkgs.libnotify}/bin/notify-send "Mail" "$new $label"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
|
|||||||
Reference in New Issue
Block a user