mu4e: notify when messages are updated

This commit is contained in:
Jeremy Baxter 2024-07-24 14:49:01 +12:00
parent fa7ea8cc0c
commit 96dab3dbb0

View file

@ -4,7 +4,15 @@
(unless (file-exists-p mu4e-path) (unless (file-exists-p mu4e-path)
(throw 'mu4e-load-path "cannot locate mu4e load path")) (throw 'mu4e-load-path "cannot locate mu4e load path"))
(add-to-list 'load-path mu4e-path)) (add-to-list 'load-path mu4e-path))
(require 'mu4e) (require 'mu4e)
(defun mu4e-notify-new-messages ()
(let ((message-count (plist-get mu4e-index-update-status :updated)))
(unless (eq message-count 0)
(shell-command (format "notify-send mu4e \"%d new messages\""
message-count)))))
(setq mu4e-maildir "~/mail" (setq mu4e-maildir "~/mail"
mu4e-get-mail-command "mbsync -a" mu4e-get-mail-command "mbsync -a"
mu4e-update-interval (* 5 60) mu4e-update-interval (* 5 60)
@ -16,6 +24,7 @@
mu4e-maildir-shortcuts '(("/Inbox" . ?i) mu4e-maildir-shortcuts '(("/Inbox" . ?i)
("/Archive" . ?a) ("/Archive" . ?a)
("/Drafts" . ?d))) ("/Drafts" . ?d)))
(add-hook 'mu4e-index-updated-hook 'mu4e-notify-new-messages)
(global-set-key (kbd "C-c m") 'mu4e) (global-set-key (kbd "C-c m") 'mu4e)
;; smtp ;; smtp