Proposal: passing user idle time to systemd-logind

Martin Flöser mgraesslin at kde.org
Mon May 27 07:34:42 BST 2019


Am 2019-05-24 21:51, schrieb Aleix Pol:
> On Wed, May 22, 2019 at 6:13 PM Germano Massullo
> <germano.massullo at gmail.com> wrote:
>> 
>> Hello, I am writing to you to propose the following reasoning, hoping
>> that it can help making easier (just a bit) third parties development
>> work on Linux.
>> I am currently developing BOINC client user idle time detection on
>> Linux systems (both graphical or tty sessions)
>> After some studies I started writing a little piece of code that that
>> is able to print on standard output the user idle time by retrieving
>> it from systemd-logind IdleSinceHint property (that is exposed on
>> DBus). By the way I found out that this value was always 0 [1], so I
>> asked why [2]. I have been told that logind relies on the desktop
>> environment to pass this information.
>> Many d.e. expose user idle time to their own DBus path, (i.e.
>> org.gnome.Mutter.IdleMonitor), so I will be forced to write code that
>> depends on the specific desktop environment. Since:
>> 1) systemd-logind is just ready for exposing user idle time;
>> 2) for a developer writing code for Linux it would be much easier to
>> retrieve user idle time from a unique place rather than having to deal
>> with all various desktop environments;
>> I would like to ask you what do you think about passing the user idle
>> time to logind [3] [4] ?
>> 
>> Best regards
>> 
>> [1]: you can try with system console command
>> $ sleep 2 && gdbus introspect --system --dest org.freedesktop.login1
>> --object-path /org/freedesktop/login1 | grep IdleSinceHint
>> [2]: 
>> https://lists.freedesktop.org/archives/systemd-devel/2019-May/042726.html
>> [3]: 
>> https://www.freedesktop.org/wiki/Software/systemd/writing-desktop-environments/
>> [4]: 
>> https://www.freedesktop.org/wiki/Software/systemd/writing-display-managers/
> 
> We are using the kidletime framework to do that on our applications:
> https://api.kde.org/frameworks/kidletime/html/index.html
> 
> IIRC, In X11 it happens through mere X11 observation, in wayland
> there's a protocol for that,
> It could make sense to expose this data to logind and even consume it
> like that from applications. Why not.

When implementing kidletime support for Wayland I also looked at the 
logind property and came to the conclusion that it's totally useless. 
The property provides the idle time. But that is not what anybody is 
interested in. What one needs are notifications (to the application) 
like idle for five minutes. That's exactly what kidletime provides.

The problem with the idle time in logind is that it keeps 3 applications 
busy:
* the Wayland compositor needs to update the time, although it's 
currently sleeping
* applications need to actively poll the logind property to check how 
much has passed
* logind is kept busy due to the polling of the applications and due to 
the compositor updating the property.

I'm all for having something standardized, ideally working on both X11 
and Wayland, but the logind interface is unfortunately not the solution.

We can add support for logind but it would be very cross. E.g. only 
providing idle for one minute, idle for five minutes, 10 minutes, 15 
minutes, 30 minutes, one hour. Everything else just causes too much 
stress on the sleeping KWin (I like KWin best when it's sleeping ;-) ).

Cheers
Martin


More information about the Plasma-devel mailing list