-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 =pod In case you didn't know, I use L as my window manager. A companion application is L, which draws the status bar at the top of the screen. My configuration pipes the output of xmonad into xmobar, so that xmobar reflects xmonad's status. Anyway, although I usually spend my time in Emacs, sometimes I am off on another desktop working away. This is a problem because if someone messages me on IRC (or IM, or Twitter, since I treat both of those as IRC), I don't get any notification, because the notification only happens in the Emacs window. I have some extra space in xmobar, so I thought it would be nice to have the notification appear there too. Making this happen is actually very straightforward. rcirc calls a hook whenever the notification string changes, so it's a simple matter of writing this to a pipe for xmobar to pick up. I have some code that does just that L It is longer than you might guess because it also converts the emacs colors into HTML-style colors (and tags) for xmobar. That way you get the same colors you've configured in emacs in your xmobar notification area too. Pretty! The second part of the equation is to get xmobar to read the notification data and incorporate it into its display. I looked at the docs, and it claims there is a PipeReader plugin that will read a pipe and merge the text in with whatever else xmobar is displaying. Perfect! I could not get this to work (a rant for another day), so I devised a clever workaround. The way xmonad feeds its status into xmobar is via a UNIX pipe. My C<.xinitrc> ends with: exec xmonad | xmobar ~/.xmonad/mobar.conf All I needed to do was write a utility to merge my emacs notification pipe with xmonad's STDOUT, and pass that merged stream into xmobar. Thus, in about a half-hour, L was born. C takes an arbitrary number of pipes as command line arguments, and then sets up an event loop that reads lines from each pipe, merges the contents with stdin, and prints the result to stdout. (Merges happen whenever any pipe has a complete line. You don't have to wait for stdin to be written to before getting the result on stdout. Play with it and see, it's pretty cool.) Now I had all the tools I needed. I rewrote my .xinitrc to call pmerge: rm -f ~/tmp/emacs.fifo mkfifo ~/tmp/emacs.fifo exec xmonad | pmerge ~/tmp/emacs.fifo | xmobar ~/.xmonad/mobar.conf I then made one change to my xmonad config, namely telling it to print a "[_1]" after its other output, so pmerge would know where to merge in the output. (The first pipe is [_1], the second is [_2], etc.) rcirc notifications in xmobar! A simple matter of programming! This appears to work well. I now need to hack rcirc to test if a buffer is actually visible before deciding not to notify me; this way, even if an irc window is being displayed in emacs, I will still get the notification if I am on another desktop. (This is easy enough with some code like: lang:Emacs-Lisp ;; determine if a buffer is visible to the user (reduce #'and (mapcar (lambda (x) (eq x t)) ;; frame-visible-p returns other true values (mapcar #'frame-visible-p (mapcar #'window-frame (get-buffer-window-list "" nil t)))) Except, of course, you can't C over C<#'and> in Emacs Lisp, as it's a special form, not a function, and special forms are not funcallable like they are in CL. So until I write my own C function, this will have to wait. Bah humbug!) One other thing; I decided to write C in Haskell. It ended up going together really quickly; I don't think I could have written it any faster in Perl. It turns out that "quick scripts" don't "need" dynamic typing or interactive development; you can write them in well-typed, purely functional, compiled style just as easily. (Even throwing in "advanced concepts" like monad transformers doesn't really slow you down!) It is all about having the right libraries and language features, and Haskell has both. If you have been thinking, "I should really try Haskell, but it's just academic wanking", think again... it is as good for quick scripts as it is for your PhD thesis. Try it, you'll like it! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqTWeQACgkQ2rw+dVvzZm2AXwCfb/XIthPkv+HKfZ4TWQRvrSAK O/8An1noolRtdvX2CFjqSn2LtgGsjSdG =kj11 -----END PGP SIGNATURE-----