Screensaver sometimes doesn't activate

On on off for many years I’ve experienced that sometimes the gnome screensaver doesn’t start/activate as usual. I come back to my computer many hours later, and the screen is still on with the desktop showing. Logging out and logging back in will “fix” it, but it is annoying, especially since I sometimes sleep in the same room as the desktop machine.

How do I debug and/or fix this?

Gnome settings

$ gsettings get org.gnome.desktop.screensaver idle-activation-enabled
true

$ gsettings get org.gnome.desktop.session idle-delay
uint32 300

$ gsettings get org.gnome.desktop.screensaver lock-enabled
false

I have disabled Power / Automatic Suspend because it is also a web-server.

What I’ve tried

I’ve noticed that if I’m e.g. running vlc, it will temporarily disable the screensaver so that the screensaver doesn’t kick in while watching the movie. When I exit vlc, the screensaver activates again after idle-delay. So I was thinking: Perhaps I ran some program that disabled the screensaver. But with vlc is running, I still see:

$ gsettings get org.gnome.desktop.screensaver idle-activation-enabled
true

So apparently vlc manages to temporarily disable the screensaver in a way that isn’t reflected by org.gnome.desktop.screensaver idle-activation-enabled.

Is there any way to see that vlc has temporarily disabled the screensaver?

I thought that kill -9 $(pgrep vlc) would leave the screensaver disabled, but the screensaver starts activating again as intended, so I haven’t managed to reproduce the problem on demand.

I have found that once it starts happening, it will continue to happen in that desktop session. Logging out and logging back in does re-activate the screen saver so things start working as normal again.

My Environment

I’m running Gnome 45.5 on NixOS 23.11 under wayland but I’ve seen this screensaver-is-not-100%-reliable behavior on many previous versions of Gnome (mostly on Ubuntu and Xorg) going back many years. So this is not new and not NixOS or wayland-specific.

Perhaps not relevant: I also have a KVM switch in front of both my work laptop (also Gnome) and my NixOS desktop (exhibiting the problem)

That’s correct, idle-activation-enabled is a user setting that apps should not mess with (and if they are sandboxed, can’t change).

There is a D-Bus API to temporarily inhibit certain actions, you can list existing inhibitors with

$ gnome-session-inhibit --list
1 Like

Thank you!

Before starting vlc:

$ gnome-session-inhibit --list
virt-manager: Automounting has been inhibited for USB auto-redirecting (automount)

After starting vlc, an extra (idle) inhibitor has been added:

$ gnome-session-inhibit --list
virt-manager: Automounting has been inhibited for USB auto-redirecting (automount)
vlc: Playing some media. (idle)

Now I just need to wait for it to spontaneously happen again to see if this is a contributing factor.

(And yes, I have virt-manager running. But it does not prevent the screensaver from activating, and exiting it makes the list empty.)