Ubuntu – How to find a program which is preventing sleeping


I am noticing that recently my laptop does not go to sleep/lockout after its configured X minutes of inactivity like it did in the past. I suspect some program (like media player does) is preventing it from going to sleep. I do not have any media player running, so how can I find which program is preventing it from sleeping?

It does go to sleep if I close the lid. But I would also like for it to go to sleep after X minutes of inactivity.

Update: Upgraded to Ubuntu 18.04 with default Gnome and Wayland enabled.

Best Answer

I think I figured it out.

I used:

dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors

to get the list of inhibitors, like:

array [
   object path "/org/gnome/SessionManager/Inhibitor71"
   object path "/org/gnome/SessionManager/Inhibitor72"

Then I did:

dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager/Inhibitor71 org.gnome.SessionManager.Inhibitor.GetAppId

Which returned:

string "firefox"

It seems Firefox is preventing it. It seems that now when YouTube is playing it prevents sleeping.

Related Question