@Niall here's the gist which can be easily modified to be a module. Anyway it adds support for connected / disconnected screen notifications, custom handlers (optional), ... Just played with it and it works. You can find example how to use it at the bottom of this gist.
P.S. Sorry for the indentation (8), I dunno why, but GitHub cripples it even if I set just 2. Maybe Safari on iPad, dunno.