I have been trying to get ERC working with notifications. Julien Danjou’s wonderful notifications module for ERC is great, but it is annoying to get notifications even when Emacs is in focus.
I had looked at circe-notifications, which has the feature but uses xdotool and xprop to do it. I was looking for something simpler, though… and it suddenly struck me that I have an auto-save hook in Emacs that is run when I focus out of it. I wondered if I could disable and enable notifications on focus, and it worked.
In case it is useful for somebody else -
(add-to-list 'erc-modules 'notifications)
(erc-notifications-mode)
(add-hook 'focus-out-hook 'erc-notifications-enable)
(add-hook 'focus-in-hook 'erc-notifications-disable)
I wonder if there are some corner cases where this doesn’t work, and that’s why the author of circe-notifications chose the tools that he did.