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

This API is now available as an Origin Trial in Chrome 84, which is the latest stable-channel release.

Sign up here to try it out: https://developers.chrome.com/origintrials/#/view_trial/551690954352885761

Subscribe to updates on https://github.com/WICG/idle-detection for news on the specification, which I am almost done with.

The Chrome Origin Trial for this API is wrapping up. Unfortunately we didn’t get participation from all the partners we wanted so we will be running a second Origin Trial which also includes the new permissions API and UX that is being added in Chrome 87. See the announcement here.

I’m planning to use this on my application to run background checks for a new version of my Angular app from my CD pipeline. Since this could consume some resources, will be better to check when the user is idle.