I started wondering a year or so ago if there's enough metadata available in my dev tools to determine if I am actively engaged in debugging or if I'm just decompressing (aka 'fucking around' according to some) on Hacker News.
If I can get that information reliably enough, I could use Automator on OS X to enable Do Not Disturb until a couple minutes after I task switch to anything else that's not focus-based.