Skip to content

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.

screenshot
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).

5 Comments

  1. Chris wrote:

    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)
    (save-excursion
    (let ((message nil)
    (chann (or (erc-default-target)
    “SERVER”)))
    (goto-char (point-min))
    (while (re-search-forward “cjb\\(.*\\)” nil t)
    (push (buffer-substring-no-properties
    (match-beginning 0)
    (match-end 0))
    message))
    (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)

    Sunday, January 28, 2007 at 4:32 am | Permalink
  2. 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.

    Sunday, January 28, 2007 at 11:55 am | Permalink
  3. tom wrote:

    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)

    Monday, January 29, 2007 at 12:24 am | Permalink
  4. It would be nice if, on OS X, the same notification code used growl instead: http://edward.oconnor.cx/elisp/growl.el

    Wednesday, February 7, 2007 at 10:25 pm | Permalink
  5. tom wrote:

    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.

    Wednesday, February 7, 2007 at 10:29 pm | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*