[systemd-devel] Detecting inactive sessions

David Herrmann dh.herrmann at gmail.com
Mon Nov 3 08:28:20 PST 2014


Hi

On Wed, Oct 29, 2014 at 3:45 PM, Bastien Nocera <hadess at hadess.net> wrote:
> For a very specific definition of inactive.
>
> I'm looking at a way for the iio-sensor-proxy at:
> https://github.com/hadess/iio-sensor-proxy
> to suspend reading from accelerometers (or maybe to turn them off), when
> all the sessions are locked and the screens turned off.
>
> This would usually mean that I would enable reading from the sensor if
> one session is "active" and stop reading if none are "active". Is this
> correct? Is it up to the session manager (eg. gnome-session) to tell us
> whether a session is active or not, or do I have this backwards?

For uhid (similar to uinput) you get an OPEN and CLOSE event whenever
the first/last user opens/closes the device you created. I think we
want something similar for uinput. That is, when a gnome session is
inactive, they should just close the input devices that were created
by iio-sensor-proxy (done automatically if you use the systemd-logind
API to access devices). This way, iio-sensor-proxy knows whenever at
least one session uses the data. This is also how most kernel-internal
APIs work.

This way, iio-sensor-proxy would get an OPEN event if at least one
user reads the data it produces, and a CLOSE event once the last user
closed the device.

Unfortunately, this requires kernel changes, which you probably want
to avoid. But a user-space solution sounds like a hack to me. You'd
have to somehow 'guess' whether there's a user of your input device.
Not sure how to make that reliable..

I wrote something up: https://gist.github.com/dvdhrm/6af5b000ddaed781764c
I can try to send this to linux-input at vger today.

One downside is that there's no way to synchronously query
iio-sensor-proxy to provide the needed information on wake-up. That
is, if the screen is turned on but iio-sensor-proxy is suspended, then
the first frame might be displayed in the wrong layout. If
iio-sensor-proxy was a kernel driver, this wouldn't happen. Similarly,
if it provided a dbus API, gnome could query it synchronously on
wake-up.
I could make the UI_EV_OPEN event synchronous, but that seems overkill
to me... hmm, not sure.

Thanks
David


More information about the systemd-devel mailing list