Puncte:0

Where to get the idle time counter when no users are logged in (no X11 sessions)?

drapel in

This situation happens when PC is just booted, or when all users are logged out from their GUI sessions.

Background: I'm developing a (yet another) fork of lightsOn.sh script which prevents idle/sleep mode when certain conditions are met, such as network connection from the given IP exists. If X11 session is available, then - no problems:

  • I take the idle counter from org.gnome.Mutter.IdleMonitor.GetIdletime from DBUS of active session,
  • compare it with configured timeout from gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
  • and schedule execution of lightson checks at the very last second before the counter reaches timeout value: loopDelay=$(( acTimeout - idleCounter - 1 )).
  • If check returns true, then I set the inhibitor: systemd-inhibit --what=sleep ....

It works. But only while someone is logged into X session. When PC is just booted, noone is logged in, then:

  • Mutter interface is not availabe in DBUS (at least, I could not find it).
  • PC successfully (magic!) goes to sleep within the time defined in sleep-inactive-ac-timeout, using gsettings of gdm user. So the system is definitely uses some idle counter. I hope it is exposed somewhere in DBUS. At least, it is good to know which process is responcible for idle counter in this scenario.

I've found some processes running under gdm user, such as gnome-session-binary, gsd-power, gnome-shell. So searched through dbus of gdm user, but Mutter is not available there:

$ sudo -u gdm bash <<< "export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/125/bus; \
gdbus call --session --dest org.gnome.Mutter.IdleMonitor \
--object-path /org/gnome/Mutter/IdleMonitor/Core \
--method org.gnome.Mutter.IdleMonitor.GetIdletime"
Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Mutter.IdleMonitor was not provided by any .service files

Alternate approach: is to monitor and catch some PrepareForSleep signal in the systemd/logind's chain, then perform checks. But I guess it's too late to set the inhibitor - system will go sleep anyway. Have to investigate.

The question is relevant to the recent Ubuntu 20.04 distribution, or to the similar distribution based on systemd, logind, Gnome 3... Older systems using obsolete Power Management architecture are out of scope.

Postează un răspuns

Majoritatea oamenilor nu înțeleg că a pune multe întrebări deblochează învățarea și îmbunătățește legătura interpersonală. În studiile lui Alison, de exemplu, deși oamenii își puteau aminti cu exactitate câte întrebări au fost puse în conversațiile lor, ei nu au intuit legătura dintre întrebări și apreciere. În patru studii, în care participanții au fost implicați în conversații ei înșiși sau au citit transcrieri ale conversațiilor altora, oamenii au avut tendința să nu realizeze că întrebarea ar influența – sau ar fi influențat – nivelul de prietenie dintre conversatori.