ExtensionsAPI reference
connect.idle
System idle state — query, threshold, and state-change events.
Read the system's idle state and react to transitions between active, idle, and locked.
- Capability:
idle - Namespace:
connect.idle
Walkthrough
Back off work while the user is away.
- Declare
idle:{ "capabilities": ["idle"] } - Subscribe to transitions:
connect.idle.onStateChanged((s) => s === 'active' ? resume() : pause()); - Or poll the current state with
queryStatewhen you need a one-off check.
Methods
idle.queryState(detectionInterval?)
Get the current state.
How to use it
- Optionally pass a
detectionInterval(seconds of inactivity →'idle'). await'active'/'idle'/'locked'.
Signature — connect.idle.queryState(detectionInterval = 60)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
detectionInterval | number | no | Seconds of inactivity before 'idle' (default 60). |
Returns — Promise<'active' | 'idle' | 'locked'>.
if (await connect.idle.queryState(120) === 'active') poll();idle.setDetectionInterval(seconds)
Set the threshold used for the 'idle' classification.
How to use it
- Pass the number of idle seconds you want to count as
'idle'.
Signature — connect.idle.setDetectionInterval(seconds) · Returns Promise<void>.
Events
idle.onStateChanged(cb)
Fires on a state transition (inactivity crossing the threshold, or lock/unlock).
How to use it
- Subscribe once.
- Pause heavy work on
'idle'/'locked', resume on'active'.
Payload — 'active' | 'idle' | 'locked'.
connect.idle.onStateChanged((state) => {
if (state === 'locked') pauseWork();
});Notes
- Use
idleto back off polling / heavy work while the user is away, and resume on'active'.