UP | HOME

Rcirc Desktop Notifications

Emacs supports desktop notifications with dbus and rcirc supports hooking receive message, this glues them together to add notifications when someone sends you a private message or uses your nickname in a channel ("highlights" you).

(require 'rcirc)
(require 'notifications)

(add-hook 'rcirc-receive-message-functions 'rcirc-do-notifications-hook)

(defun rcirc-do-notifications-hook (process cmd sender args text)
  (let ((target (car args))
        (message (cadr args))
        (nick (rcirc-nick (rcirc-buffer-process))))
    (when (and (equal cmd "PRIVMSG")
               (not (equal sender nick))
               (or (equal target nick)
                   (string-match (concat "\\b"
                                         (regexp-quote nick)
                                         "\\b")
                                 message)))
      (notifications-notify :title sender :body message))))

You could replace notifications-notify with whatever event you want to trigger when you're "highlighted". notifications-notify has a bunch of options, you can control how long the alerts appear with timeout or key them on the senders nickname and make consecutive alerts replace the last with replace-id. This is just the simplest configuration.

If you want to trigger multiple events when you're highlighted, or just like keeping things generic, you could define your own hook and trigger it in rcirc-do-notifications-hook.