Chrome’s Apps/Extensions API includes chrome.idle.*
(docs) which allow querying and receiving notifications about the user degree of interaction with the device, categorized as “active”, “idle”, and “locked”. This is a feature used by chat apps to show some indicator of user activity/inactivity.
Several JS libraries have been created that distinguish active/idle within the context of a window (idle.ts, idle.js). These are necessarily limited to just watching for UI events, and can’t detect screen lock and other cases where the browser has more knowledge like activity in other tabs.
This seems like an API that would be useful for the browser to expose to script, modulo appropriate user permission. I’ve written up an Explainer which at this point just proposes adapting the extension API for the web practically as-is. It looks like Firefox and Edge also support this API for extensions, so browsers have some of the plumbing already.
Is there any other interest in such an API? Feedback here or in the repo would be appreciated.