Idle Detection API

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.

3 Likes

We’d definitely be interested in this at Slack. Right now we use an Electron API to make this work, but it’d be great to avoid that and make this consistent across our web and Electron versions!

1 Like

We would be interested in this API for Google Chat. The API would be useful to decide which device to send notifications to based on a user’s idle state.

Chairs (@marcosc @cwilso @yoavweiss @travisleithead), can we get the repository above migrated into the WICG for further incubation of this proposal?

Done. https://github.com/WICG/idle-detection