Emacs versus notification area

I’ve occasionally wanted Emacs to be able to put an icon into the status area, so that I can set it up to notify me when interesting things happen; say, when a compilation finishes. I’ve also been thinking of moving my calendar into Emacs, and I didn’t want to lose out on Evolution’s nice appointment notification feature.

So, tonight I hacked up zenity to add a little more functionality to its notification mode. In particular I changed it so that left click will print some (user-specified) text, and so that a right-click menu can be set up as well.

After that it was pretty simple to write some Emacs code to wrap up zenity in a nicer API.

Now all that remains is to hook this up to things inside Emacs. I’ve got my compilation mode hook set already; next I suppose I’ll investigate the calendar, or perhaps erc. Send me email if you want the lisp (my zenity patch is in Gnome bugzilla).


  • Sounds good, please send!

    I have ERC hooked up to notify-send with the following (which clearly shows that I don’t know how to write elisp):

    (defun my-scan-erc-message ()
    (require ‘erc-button)
    (let ((message nil)
    (chann (or (erc-default-target)
    (goto-char (point-min))
    (while (re-search-forward “cjb\\(.*\\)” nil t)
    (push (buffer-substring-no-properties
    (match-beginning 0)
    (match-end 0))
    (when message
    (shell-command (mapconcat (lambda (str) (format
    “notify-send -i gtk-dialog-info -t 300000 — \”%s\” \”%s\”” chann str))
    message “\n”))))))

    (add-hook ‘erc-insert-modify-hook ‘my-scan-erc-message)

  • You probably have my email address already, but please do also post the lisp code (as a comment or to download) so the rest of the world can share it.

  • BTW, Chris, with the new code this looks like:

    (setq my-process (status-new))
    (defun my-erc-hook (match-type nick message)
      (and (eq match-type ‘current-nick)
           (not (erc-buffer-visible (current-buffer)))
           (status-post-message my-process
                                (concat “message on chan ”
                                        (buffer-name (current-buffer))))))
    (add-hook ‘erc-text-matched-hook ‘my-erc-hook)

  • It would be nice if, on OS X, the same notification code used growl instead: http://edward.oconnor.cx/elisp/growl.el

  • My status.el hack does more than just notify — you can also have the icon blink, you can handle a mouse click on the icon, and you can have a right-click menu on the icon.

    Ideally this would be built in to Emacs so no external program is needed. That looked like too much work at the time.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>