Wednesday, March 06, 2013

rcirc + growl + convos on windows

How to growl with rcirc to get notified about convos:
Being annoyed about missing a convo with rcirc, I decided to get emacs to play a sound when somebody says something in a convo. Playing a sound with emacs is easy (play-sound '(sound "c:/path/file.wav")). Then I remembered that's to oldschool, I need to use growl. So here's my setup:


Ingredients

  1. Growl for Windows
  2. todochiku
  3. some elisp code

First install growler. Then because it disables M-x while it runs, we'll edit the config file c:/Documents and Settings/<USERNAME>/Local Settings/Application Data/Growl/2.0.0.0/user.config. Look for Alt+X and replace it with a combo you won't need, like Alt+Z.


Then install todochiku and configure it, specifically change the todochiku-command to c:/Programm Files/Growl for Windows/growlnotify.exe or whereever you installed growl. If you want icons get it from EmacsWiki: To Do Chi Ku and customize the todochiku-icons-directory to wherever you unpacked the icons.
Congratulations, you can now growl from within Emacs with (growl "Emacs here" "growling is a go").

The last step is to add some more code to get notified about hidden convos. The code below does that and redefines the hook that already comes with todochiku to include the text that mentions your nick.


(defun growl-convo-rcirc-print-hook (process sender response target text)
  (when (and (string= sender target)
             (not (string= (rcirc-nick process) sender))
             (not (string= (rcirc-server-name process) sender))
             (not (memq (rcirc-get-buffer process target t)
                        (rcirc-visible-buffers))))
    (todochiku-message "IRC convo" (format "<%s> %s" sender text) 'social)))
(add-hook 'rcirc-print-hooks 'growl-convo-rcirc-print-hook)

(defun growl-rcirc-print-hook (process sender response target text)
  (when (and (rcirc-channel-p target)
             (string-match (rcirc-nick process) text)
             (not (string= (rcirc-nick process) sender))
             (not (string= (rcirc-server-name process) sender)))
    (todochiku-message (format "IRC mention" target)
        (format "%s <%s> %s" target sender text)
        'social)))

No comments: