idle

The idle API allows an extension to detect when the user's machine is idle, active, or locked.

What it does

  • Determine the machine's current state: active, idle, or locked.
  • Set an idle detection interval. By default, the system is considered idle if there is no user input for 60 seconds.
  • Listen for an onStateChanged event that fires whenever the machine's state changes.

When to use it

This is useful for extensions that change their behavior based on user activity.

Examples:

  • A chat application that automatically sets the user's status to "away" when they become idle.
  • A time-tracking extension that pauses its timer when the user is idle.
  • A security extension that performs an action (like logging out) when the screen is locked.
  • An extension that delays non-essential background tasks until the user is idle to conserve resources.

Manifest Declaration

{
  "name": "My Idle-Aware Extension",
  "version": "1.0",
  "manifest_version": 3,
  "permissions": [
    "idle"
  ],
  "background": {
    "service_worker": "background.js"
  }
}

Security & Privacy

Why is it not risky?

This permission allows an extension to know if you are actively using your computer or if you are away (idle). For example, a chat app might use this to automatically set your status to "Away".

This is a safe permission. It does not give the extension access to what you are doing, only that you are doing something. The minor privacy risk is that it can learn your usage patterns (e.g., when you typically take breaks), but it cannot see any of your personal data.

API Usage Example

This example logs a message to the console whenever the user's state changes from active to idle.

// background.js

console.log('Idle API listener started.');

// Set the detection interval to 30 seconds.
chrome.idle.setDetectionInterval(30);

chrome.idle.onStateChanged.addListener((newState) => {
  const timestamp = new Date().toLocaleTimeString();
  console.log(`[${timestamp}] Machine state changed to: ${newState}`);

  if (newState === 'idle') {
    console.log("User is now idle. Pausing activities.");
  } else if (newState === 'active') {
    console.log("User is active again. Resuming activities.");
  }
});

Extensions with the idle permission

Here are some popular browser extensions that use the "idle" permission. To explore more, try our Advanced search.

Permission Metrics

Popularity

Security Risk


Usage by Platform