[[./screenshot.png]]
Inspired by [[https://github.com/tomterl][tomterl]] on =#emacs-circe= who posted [[https://github.com/jorgenschaefer/circe/wiki/Configuration#tracking-send-desktop-notifications-on-buffer-activity][this]] configuration snippet, and Julien Danjou's [[http://julien.danjou.info/blog/2012/erc-notifications][erc-desktop-notifications]]. Requires Circe >= 2.0.
** Features
** Configuration
*** GNU/Linux
(autoload 'enable-circe-notifications "circe-notifications" nil t)
(eval-after-load "circe-notifications" '(setq circe-notifications-watch-strings '("people" "you" "like" "to" "hear" "from")))
(add-hook 'circe-server-connected-hook 'enable-circe-notifications)
Uses =dbus= to connect to your DE/WM's particular notification system.
*** OSX
(autoload 'enable-circe-notifications "circe-notifications" nil t)
(eval-after-load "circe-notifications" '(setq circe-notifications-watch-strings '("people" "you" "like" "to" "hear" "from") circe-notifications-alert-style 'osx-notifier)) ;; see alert-styles for more!
(add-hook 'circe-server-connected-hook 'enable-circe-notifications)
** Caveats
If you use the configuration above with something like ZNC you will endure a deluge of notifications upon buffer playback.
Short of patching a new RPL code into both ZNC and Circe specifically for this, the only way to deal with it is to compare the number of notices received from ZNC so far to the number of notices you expect to receive from ZNC.
The number of notices depends on how many networks you are connecting to and how many lines are in ZNC's MOTD. It's a massive kludge but here's how I do it. Replace the line =(add-hook 'circe-server-connected-hook 'enable-circe-notifications)= from the configuration snippet above with something like this:
;; Warning: this is very dumb ;; ;; ZNC's MOTD is 25 lines. ;; I have two networks defined in `circe-network-options'. ;; So wait to see 50 notices from ZNC before enabling notifications.
(defvar eqyiel-circe-znc-notices 0 "How many notices have we received from ZNC?")
(defvar eqyiel-circe-znc-motd-length 25 "How many lines are in ZNC's MOTD?")
(defun eqyiel-circe-znc-count-networks ()
"Return the number of networks in circe-network-options' multiplied by
eqyiel-circe-znc-motd-length', so we can know how many notices to expect before
enabling notifications."
(* eqyiel-circe-znc-motd-length (length circe-network-options)))
(defun eqyiel-circe-wait-for-znc (nick userhost _command target text)
"If this TEXT from NICK and USERHOST looks like a line of ZNC's MOTD,
increment eqyiel-circe-znc-notices', and enable notifications if there have been at least
eqyiel-circe-znc-count-networks' `eqyiel-circe-znc-notices'."
(when (and (string-equal nick "*status")
(string-equal userhost "znc@znc.in"))
(setq eqyiel-circe-znc-notices (+ 1 eqyiel-circe-znc-notices))
(message "That's %d ..." eqyiel-circe-znc-notices)
(when (<= (eqyiel-circe-znc-count-networks) eqyiel-circe-znc-notices)
(message "OK.")
(advice-remove 'circe-display-NOTICE 'eqyiel-circe-wait-for-znc)
(enable-circe-notifications))))
(defun eqyiel-enable-circe-notifications () (interactive) (advice-add 'circe-display-NOTICE :after 'eqyiel-circe-wait-for-znc) (advice-add 'circe-reconnect-all :before 'eqyiel-disable-circe-notifications))
(eval-after-load 'circe '(eqyiel-enable-circe-notifications))
(defun eqyiel-disable-circe-notifications () (interactive) (disable-circe-notifications) (setq eqyiel-circe-znc-notices 0) (advice-add 'circe-display-NOTICE :after 'eqyiel-circe-wait-for-znc))
Alternatively, you can =M-x enable-circe-notifications= after the buffer playback is done.