Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help to get desktop notifications every X minutes #42

Open
fabriziojpiva opened this issue Sep 30, 2021 · 2 comments
Open

Help to get desktop notifications every X minutes #42

fabriziojpiva opened this issue Sep 30, 2021 · 2 comments

Comments

@fabriziojpiva
Copy link

Hi everyone. I have installed mu4e-alert correctly and set up the configuration in my .emacs as follow:

;; mu4e alert for notifications
(require 'mu4e-alert)

(setq mu4e-alert-interesting-mail-query
      (concat
       "flag:unread AND maildir:/google/INBOX "
       "OR "
       "flag:unread AND maildir:/outlook/Inbox "
       "OR "
       "flag:unread AND maildir:/work/INBOX"
       ))

(mu4e-alert-set-default-style 'libnotify)
(add-hook 'after-init-hook #'mu4e-alert-enable-notifications)
(add-hook 'after-init-hook #'mu4e-alert-enable-mode-line-display)

(defun refresh-mu4e-alerts ()
  (interactive)
  (mu4e~proc-kill)
  (mu4e-alert-enable-mode-line-display)
  )

(run-with-timer 0 60 'refresh-mu4e-alerts)

However, the desktop notifications only work when I open Emacs, in that exact moment I get the notifications of the unread emails correctly. But after that, when Emacs is already open for a couple of minutes and I receive a new email, I only get the line-display icon updated but without any desktop notification. Is it possible to configure the desktop notifications to also work when Emacs is already running?

@archer-65
Copy link

Hi everyone. I have installed mu4e-alert correctly and set up the configuration in my .emacs as follow:

;; mu4e alert for notifications
(require 'mu4e-alert)

(setq mu4e-alert-interesting-mail-query
      (concat
       "flag:unread AND maildir:/google/INBOX "
       "OR "
       "flag:unread AND maildir:/outlook/Inbox "
       "OR "
       "flag:unread AND maildir:/work/INBOX"
       ))

(mu4e-alert-set-default-style 'libnotify)
(add-hook 'after-init-hook #'mu4e-alert-enable-notifications)
(add-hook 'after-init-hook #'mu4e-alert-enable-mode-line-display)

(defun refresh-mu4e-alerts ()
  (interactive)
  (mu4e~proc-kill)
  (mu4e-alert-enable-mode-line-display)
  )

(run-with-timer 0 60 'refresh-mu4e-alerts)

However, the desktop notifications only work when I open Emacs, in that exact moment I get the notifications of the unread emails correctly. But after that, when Emacs is already open for a couple of minutes and I receive a new email, I only get the line-display icon updated but without any desktop notification. Is it possible to configure the desktop notifications to also work when Emacs is already running?

Same problem. I can't live without notifications.

@PiotrBosak
Copy link

Hi, I had the same problem and I've come up with a hack to solve it.

(require 'mu4e-alert)
(add-hook 'mu4e-index-updated-hook (lambda ()
(mu4e-alert--get-mu-unread-mails (lambda (mails)
                                         (mu4e-alert-notify-unread-messages-count (length (mu4e-alert-filter-repeated-mails mails)))))))

I added that hook and it shows a notification whenever you index your mail(which mu4e does on its own when it synchronizes, to modify how often mu4e synchronizes, use (setq mu4e-update-interval <seconds>)

You can look at the mu4e-alert source to come up with something better, this will only print how many mails you got.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants