Notification for notmuch upon new email arrival.
Features:
- Notification and sound effect upon new email arrival.
- Different alerts can be customized for different emails set.
- Message on the the number of messages whenever
notmuch-hello
is refreshed.
The following configuration relies on quelpa-use-package, but it is
straightforward to clone this repo locally and use use-package
instead.
Moreover, this package uses alert
as notification backend. See jwiegley/alert
for options to fine-tune notifications (especially alert-default-style
).
Below is a minimal configuration. Keep reading for more customizations.
(use-package notmuch-notify
:ensure t
:quelpa (notmuch-notify :fetcher github :repo "firmart/notmuch-notify")
;; (Recommended) activate stats message when refreshing `notmuch-hello' buffer
:hook (notmuch-hello-refresh . notmuch-notify-hello-refresh-status-message)
:config
;; (Recommended) activate system-wise notification timer
(notmuch-notify-set-refresh-timer))
An important feature of notmuch-notify
is that it allows you to define
severity, title, icon or audio per emails basis. This is done by configuring the
variable notmuch-notify-alert-profiles
which defines a list of alert
profiles. An alert profile is a property list with the properties :name
,
:search-term
, :severity
, :title
, :icon
and :audio
. The value of the
last four, if missed, will fall back to their corresponding variable
notmuch-notify-alert-default-*
. Whereas the :name
is merely for debugging
purpose, the role of :search-term
is central. It takes a notmuch search term
to specify on which emails set the notification will be performed.
Here is an example of further customization. It firstly excludes all emails
having the notmuch tags Org-Mode
and FromMe
. It then reduces the email
checking interval to 10 seconds. Finally, it sets two alert profiles:
- The
inbox
profile will match all emails tagged asinbox
(but not those tagged asOrg-Mode
andFromMe
), will change the title toNotmuch inbox:
and change the icon and audio accordingly. - The
default
profile will match any email which is not tagged asinbox
,Org-Mode
orFromMe
. Its:severity
,:title
,:icon
and:audio
are the default ones (see below).
(setq notmuch-notify-excluded-tags '("Org-Mode" "FromMe"))
(setq notmuch-notify-refresh-interval 10)
(setq notmuch-notify-alert-profiles
`((:name "inbox"
:search-term "tag:inbox"
:severity urgent
:title "Notmuch inbox:"
:icon ,(expand-file-name "img/inbox.jpg" user-emacs-directory)
:audio ,(expand-file-name "audio/inbox.mp3" user-emacs-directory))
(:name "default")))
This is a table of customizable variable, their default value and description.
Variable | Default value | Note |
---|---|---|
notmuch-notify-alert-profiles | (see C-h v notmuch-notify-alert-profiles ) | Alert profiles. Customize different notifications for different emails. |
notmuch-notify-alert-default-severity | symbol: normal | Available symbols: trivial , low , normal , moderate , high , urgent . See jwiegley/alert. |
notmuch-notify-alert-default-title | string: Notmuch: new message | Notification title. |
notmuch-notify-alert-default-icon | string: notmuch-logo.png (Notmuch official logo) | Notification icon. |
notmuch-notify-alert-default-audio | string: emailreceived.wav (Robot voice: “email received”) | Notification audio. |
notmuch-notify-alert-default-audio-program | string: mpv | Program to play notification audio. |
notmuch-notify-excluded-tags | string list: nil | List of notmuch tags to exclude unconditionally from any notification. |
notmuch-notify-refresh-interval | number: 60 (seconds) | Interval between two check of unread messages. |
- Support actions for some profiles: e.g. repeat notification <x> times during <interval> until the email being read etc.
- Make some data persistent in the disk to notify new emails during emacs down.
Issues and PRs are welcomed.
- Notmuch: Emacs tips for the status refresh function.
- System notification inspired from wlemuel/alarm-clock.
- Default sound effect (
emailreceived.wav
) comes from Freesound (CC0). - Default icon is Notmuch official logo.