Complete Computing Environment: Notifications

Table of Contents

Notifications using Sauron

Sauron is a notifications framework, more or less. It presents a Sauron buffer that will show you pings in IRC and Jabber, email notifications, twitter updates and can even be fed using D-BUS to bring in external applications' notifications.

(provide 'cce-sauron)
(install-pkgs '(sauron))
(require 'sauron)

Sauron events can have different priority, which we can set when we call the Sauron event emission function, or based on rules defined below. When an event is added, we can optionally act on it based on the message or priority or origin.

(add-hook 'sauron-event-added-functions
          (lambda (origin prio msg &optional props)
            (emacspeak-speak-string msg nil)
            (emacspeak-auditory-icon 'new-mail)
(add-hook 'sauron-event-added-functions
          (lambda (origin prio msg &optional props)

These variables control, more or less, ways which we modify the priority of different Sauron events, such as when they are directed towards me, or something I work on.

(setq sauron-max-line-length 0
      sauron-nick-insensitivity 5
      sauron-watch-nicks '("rrix" "RyanRix" "M-RyanRix")
      sauron-watch-patterns '("emacsconf" "dongiverse" "fsem" "@all" "@here" "@haveyoumettod" "rrix"))


(setq sauron-prio-twittering-new-tweets 2)
(setq twittering-username "rrrrrrrix")
(add-hook 'twittering-new-tweets-hook

(defun sauron-twittering-check-tweet-direct-func ()
  "Hook which takes newly incoming tweets and adds sauron events
for any mentioning `twittering-username'. Events will be added
using `sauron-prio-twittering-mention' priority."
  (when (and twittering-username
             (boundp 'twittering-new-tweets-statuses))
    (dolist (tweet twittering-new-tweets-statuses)
      (when (equal
             (alist-get 'source-spec tweet))
         (format "%s: %s"
                 (alist-get 'user-screen-name tweet)
                 (alist-get 'text tweet))
             ((tweets-spec twittering-new-tweets-spec)
              (tweets-data twittering-new-tweets-statuses)
              (tweets-count twittering-new-tweets-count))
           (lambda ()
              tweets-data tweets-count tweets-spec))))))))

Gnus / Email notifications

I use gnus-desktop-notify, which allows you to use alert.el or notifications.el which means I can feed them in to Sauron using the Sauron Notifications module.

(install-pkgs '(gnus-desktop-notify))

Make sure the Notifications always get pushed in to Sauron.

(setq sauron-notifications-urgency-to-priority-plist
      '(:low 3 :normal 4 :critical 5 :otherwise 3))
(setq alert-user-configuration (quote ((nil notifications nil))))

This sets up Gnus to scan my Level 2 newsgroups every 2 minutes if I am idle. If there are new messages, it'll trigger the notifications and push them in to Sauron

(defun gnus-demon-scan-news-3 ()
  (let ((win (current-window-configuration))
        (gnus-read-active-file 'some)
        (gnus-check-new-newsgroups nil)
        (gnus-verbose 2)
        (gnus-verbose-backends 5)
        (level 1))
    (message "check-mail: %s" (format-time-string "%H:%M:%S"))
            (when (gnus-alive-p)
              (with-current-buffer gnus-group-buffer
                (gnus-group-get-new-news level))))
        (set-window-configuration win)))))

(if (memq 'cce-server-minor-mode minor-mode-list)
    (setq gnus-demon-timestep 60)
  (setq gnus-demon-timestep 10))
(add-hook 'gnus-started-hook (lambda ()
                               (gnus-demon-add-handler 'gnus-demon-scan-news-3 60 1)))

DONE Keybinding to jump to *Sauron* buffer

(defun cce/show-sauron ()
  "Show Sauron in a pop up window."
  (display-buffer (get-buffer "*Sauron*") '(display-buffer-in-side-window
                                            ((window-height . 20)
                                             (inhibit-same-window t)
                                             (side right)))))
(global-set-key (kbd "<f2> s") #'cce/show-sauron)

Author: Ryan Rix

Created: 2017-03-31 Fri 15:22

Validate XHTML 1.0