runwhenidle
runwhenidle copied to clipboard
Avoid polling every second
Why use polling when you can use interrupts? There is an idlehint bool in org.freedesktop.login1.session at /org/freedesktop/login1/session/auto and you can get notified when it changes by subscribing to the corresponding PropertiesChanged dbus signal.
It would be much more elegant than the current implementation that polls actively every second. And it would also get rid of the X11 dependency.
It should be noted though that idlehint is not properly set right now in KDE Plasma: https://bugs.kde.org/show_bug.cgi?id=448942
But that should not be a showstopper, I might fix this bug in KDE over the weekend.
Does Gnome currently set this? I found it was not doing it in 2019 https://mail.gnome.org/archives/desktop-devel-list/2019-May/msg00088.html
If yes, this would indeed be a good alternative. I think it will make sense to add support to use multiple detection methods and let the user pick which one to use.
Also I don't see polling every second as a big problem, that shouldn't be using a lot of CPU, but removing dependency on X11 would be a good thing.
Does Gnome currently set this? I found it was not doing it in 2019 https://mail.gnome.org/archives/desktop-devel-list/2019-May/msg00088.html
I don't use Gnome, so can't test the current state of this unfortunately.
Also I don't see polling every second as a big problem, that shouldn't be using a lot of CPU
Yes it's not a big problem. Nonetheless, getting rid of the polling completely would be nice to have.
It just seems like neither Gnome nor KDE support this currently :) So then this implementation would not benefit anyone until this is fixed upstream.