What is the system sleep status immediately exiting the keep.running context manager? #366
Replies: 4 comments 6 replies
-
What an interesting question! I haven't even thought about that previously. The answer unfortunately is that since wakepy is "just a wrapper around system APIs", the answer depends on the operating system and desktop environment (and their versions) used. I would have guessed that for example org.gnome.SessionManager would hold a wakelock only until the lock is released, but it actually seems to reset the sleep timer periodically, and will leave the system with zeroed-out sleep timer (so with automatic sleep after X minutes you would have to wait X minutes after keep.running context manager is exited to make the system sleep automatically): org.gnome.SessionManager testTested on Ubuntu 22.04.4, Gnome 42.9 using instructions in How to test wakepy Modes? and
I started the timer (test script) perhaps 5-20 seconds after the wakepy keepawake script. Taking the 550 out of 1137 gives 587 seconds, so the system started sleeping after ~600 seconds after the 550 second wait, and the org.gnome.SessionManager did leave the system with "zeroed" sleep timer after exiting the context manager (after uninhibit). Do you think adding information about the idle timer reset to the returned Mode instance would be useful? What kind of use case you have? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response and the mini test was exactly the type of information I was looking for. Somehow I missed the testing section in my first pass through the documentation. I'll have to run the same experiment on my system to see what happens. AFAIK, Windows will prevent your system from sleeping if it is active, but there is no such mechanism in Linux, which has bugged me for years. There are tools like Caffeine, but I basically always forget to enable them when I need to, so I don't find them very useful. At one point I found a script that more or less had the functionality I wanted but it basically only worked with Gnome and systemd. Unfortunately, I use KDE and OpenRC. Long story short, I've been happily using wakepy with a scraping project, so I thought I'd spend a couple days writing my own system utilization monitor script to prevent the system from sleeping under significant utilization. As a bit of a side note this comment intrigued me:
A long time ago, before I discovered wakepy, I scoured the web trying to find any information about the sleep timer/idle timeout counter in KDE and whether it could be reset, e.g., using dbus. At the time I couldn't find anything about it at all. Nothing about how to retrieve its current value or how to reset it. So, I find it interesting that it can at least be done with Gnome. |
Beta Was this translation helpful? Give feedback.
-
Just a quick update. I ran the test script on my system and it also appears that in KDE |
Beta Was this translation helpful? Give feedback.
-
The method was Using: |
Beta Was this translation helpful? Give feedback.
-
I am basically wondering about the situation where the system is configured to sleep after being idle for
x
minutes (e.g., 10 minutes). Wakepy then inhibits sleep forx+1
minutes. Does the system immediately go to sleep after exiting thekeep.running
context manager or is the system idle timer also reset, so the system won't actually go to sleep for anotherx
minutes after exiting? Is the behavior dependent on which operating system / desktop environment being used?Beta Was this translation helpful? Give feedback.
All reactions