How to tell gnome-session(3), or gnome-screensaver, that there's been activity?
Under some circumstances I don’t want my screen to lock. (Typically: I’m stepping away from the desk, while a computation is running, but I won’t leave the room and still have an eye on it why it’s active; sometimes, I’ll add more tasks to a queue, so that it’s not "done when it’s done")
Is there a mechanism to tell GNOME session or ~ screensaver not to lock? I was expecting there to be a clever DBUS API for that, but GNOME’s documentation seems to depend on the private homedir of someone who’s since deleted it: https://wiki.gnome.org/Projects/SessionManagement/GnomeSession#D-Bus_API links to the 404 https://www.gnome.org/~mccann/gnome-session/docs/gnome-session.html.
Even better: is there a Freedesktop standardized API for this? I mostly work on Cinnamon-session with an awesome WM, but this problem I encounter mostly on machines where I’ve only got access to a Gnome session; however, if there’s a one-size-fits-all solution, I’d greatly prefer that.
At least under X, you can use xdg-screensaver
to inhibit a compliant screensaver as long as a given window exists:
xdg-screensaver suspend <window-id>
There is a Freedesktop D-Bus interface for screensavers, which you would invoke using something like
dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call --print-reply
/ScreenSaver org.freedesktop.ScreenSaver.Inhibit
string:"myapplication" string:"displaying long computations"
but that doesn’t work from dbus-send
since it’s tied to the caller — calling it from a long-running Python script should do the trick.
(--print-reply
is included because the return value is important — it’s a cookie used to uninhibit the screensaver.)
See also Prevent system from going to sleep/suspend – how Xviewer/VLC do it