IMAGINARY / kiosk-browser

Hardened Web Browser with Kiosk-mode
Apache License 2.0
21 stars 2 forks source link

API for Idle detection #48

Open elondaits opened 4 years ago

elondaits commented 4 years ago

In exhibits it's useful / a requirement to do something when the exhibit has been idle (no touch / mouse or keyboard events for N seconds):

Unfortunately this cannot be done at app level (allegedly) because when an event (mouse, touch) is captured within an iframe the hosting page never gets a notification. Schemes to capture and forward events would be complex and hacky.

This is simple to do at OS level through various system-specific mechanisms (such as X Screensaver in Linux).

I found there is a node.js / electron module which wraps these various mechanisms: node-desktop-idle. There is more than one suitable module, actually... so some quick research should be done before implementing this feature.

So my proposal is to:

elondaits commented 4 years ago

@porst17 commented (in Slack)

The idle-detection should also be added as a cli option to just reload the page if the station is idle. That way, we can add idle-reset to exhibits that don’t support it natively.

porst17 commented 4 years ago

I am currently updating from Electron v6 to v8. While going through the list of (breaking) changes in v7 and v8, I noticed the introduction of a new API: powerMonitor

There is the method getSystemIdleTime() (number of seconds the system is idle). This is much better then using another module, because these modules are most likely using platform native APIs. Using native modules with Electron is a pain and often requires installing additional libraries on the system that aren't packaged with Electron, something I would really like to avoid.

elondaits commented 4 years ago

If this works as we assume it does it's certainly the way to go. Let's test it when we can.