Viritin just got a new helper: PageVisibility.
It wraps the browser’s visibility API but goes one better – it also considers focus, because let’s face it: “not hidden” ≠ “actually in use” (hello, multtasking, I still use IntelliJ instead of just Safari).
Cool idea! Worked really well in my simple test case using multiple screens :) Sadly it is even detecting when I’m admiring my cat GIFs in another application, no more idle (VISIIBLE_NON_FOCUS)
These are somewhat much the same use cases I solved in Idle add-on: Getting notifications and changing the application behavior when not in active use.
Despite the similarity in use cases, it is technically implemented completely differently (mouse+focus) as the Page Visibility API wasn’t that reliable and didn’t cover all the cases - at least back in those days.