jwiegley/alert

Add a windows desktop style desktop notification

Horrih opened this issue · 0 comments

Horrih commented

Hello,
Thank you for your amazing package.
In your README you suggested using the notifications package for desktop notifications.

However your package seems to be used by some popular packages out there, like org-alert for example.
Would it be possible to include a built-in style for windows desktop notifications ?

As an example (i'm an elisp newbie), here is what I ended up doing in my own init.el, using the built-in w32-notification-notify

(use-package alert
  :config
  ;; Add the windows desktop notifications if on windows
  (when (eq system-type 'windows-nt)
    (alert-define-style
     'windows-desktop-notification-style
     :title "Windows Desktop Notification style"
     :notifier
     (lambda (info)
       (let ((notif-id (w32-notification-notify :title (plist-get info :title) :body (plist-get info :message))))
         ;; Close it after 3 seconds (no new notification can be sent if left unclosed)
         (run-with-timer 3 nil `(lambda() (w32-notification-close ,notif-id))))))
    (setq alert-default-style 'windows-desktop-notification-style)))

Thank you for your amazing work for the emacs community