djcb/sauron — Issue #10: "Hook" sauron-add-event to notifications-notify
Author: tkf
Created: 2012-01-20 19:30:47+00:00
State: open

I wrote this advice to add message passed to notifications-notify to sauron.

Since notifications.el is shipped with Emacs since 24, I guess many package supports this protocol. Then sauron get messages from these packages for free.
But maybe it will be problematic if some package supports both sauron and notifications.el because you will have duplicated messages in sauron.

Anyway, do you think this can be in sauron?

(defadvice notifications-notify
(after sr-notifications-hook (&rest params))
"\"Hook\" `sauron-add-event' to `notifications-notify'"
(let ((title (plist-get params :title))
(body (plist-get params :body))
(urgency (plist-get params :urgency))
(urgency-to-prio `(low 3 normal 4 critical 5))
(prio-default 4))
(sauron-add-event
'notifications
(or (plist-get urgency-to-prio urgency) prio-default)
(concat title (if (and title body) " - ") body))))

;; activate the advice
(ad-enable-advice 'notifications-notify 'after 'sr-notifications-hook)
(ad-activate 'notifications-notify)