Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upHow to interrupt suspend? #72
Comments
Yamakuzure
added
bug
need information
labels
Aug 10, 2018
This comment has been minimized.
This comment has been minimized.
But it should. I have to investigate this. |
Yamakuzure
self-assigned this
Aug 10, 2018
This comment has been minimized.
This comment has been minimized.
I am by no means a master coder, but I've placed a simple script in the system-sleep directory to test this functionality.
The text DOES get written, but the system sleeps anyway. I also get the following item in dmesg:
I'm working with elogind-235.2 on a Gentoo system |
This comment has been minimized.
This comment has been minimized.
So everything is working just fine except the suspension isn't cancelled. That gives me a good hint about where to start looking, thank you very much! I have to ask for a bit of patience, though, I am currently migrating towards v239. |
This comment has been minimized.
This comment has been minimized.
This is the last issue open before v239 can be released. As some other issues have been fixed, too, this means new service releases for 236 and 238, too. |
This comment has been minimized.
This comment has been minimized.
@metafarion : It seems we were both mistaken. I looked up all places where stuff from SYSTEM_SLEEP_PATH and SYSTEM_POWEROFF_PATH gets executed in systemd, and the whole thing is in no way designed to even be able to react on the outcome of what it started. Or in other words: Both folders are not meant to hold anything that can interrupt a pending suspension or shutdown. However, I found out in that process, that elogind does not use /lib/elogind/system-shutdown at all. BUT before you now think that this issue is closed, let me tell you that it is not. I will simply change the type from "Bug" to "Feature Request". What would be the most elegant way to do so? A configuration option maybe? |
Yamakuzure
added
enhancement
help wanted
feature request
and removed
bug
need information
labels
Sep 28, 2018
This comment has been minimized.
This comment has been minimized.
The details of "how" are definitely out of my league. I'm no coder, just a sysadmin looking to be able to configure intelligent automatic suspend on my workstations. Virtually all window managers rely on mouse/keyboard input to keep them awake, and therefore have no respect for other conditions that might constitute "activity". I had previously been putting scripts in /etc/pm/sleep.d provided by pm-utils, which allowed me to define such conditions, but pm-utils is no longer used by many window managers. I don't even remember where I read that /lib/.../system-sleep/ could be used in the same way. If that's not the right way to do it, I can accept that; it just seemed like the sort of thing that systemd/elogind should be able to do. |
This comment has been minimized.
This comment has been minimized.
On the contrary, you are perfect! This feature must clearly be an "opt-in", so how does an actual sysadmin would like to perform such an "opt-in"? First I thought of an option to loginctl. |
This comment has been minimized.
This comment has been minimized.
If I'm understanding you, that would mean you'd have to set "allowsuspendinterrupts = 1" or something in logind.conf and then it would respect your exception scripts. That sounds like a reasonable approach to me. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
239.1 just arrived in Portage; I'm gonna try it out as soon as I get a little free time. |
This comment has been minimized.
This comment has been minimized.
@metafarion : I have not yet implemented this feature. It is, however, planned for 239.2 which is almost ready. |
added a commit
that referenced
this issue
Nov 20, 2018
Yamakuzure
closed this
in
3e423dc
Nov 20, 2018
This comment has been minimized.
This comment has been minimized.
@metafarion : I have eventually succeeded in implementing an opt-in feature to interrupt sleep/poweroff. Unfortunately the infrastructure in systemd is not written to react on exit codes from called executables. Further more everything is executed in parallel. So if you needed to have scripts be called in the exact given order, it wouldn't have worked anyway. At least not as expected. So I have added a callback function that forces the execution to become sequential, and that reacts on lines printed to STDOUT. I consider this to be an experimental feature. And I am certain it needs to be refined in the future.# Hopefully it can do what you need it to do. |
This comment has been minimized.
This comment has been minimized.
novazur972
commented
Nov 27, 2018
Sorry but I don't understand how to use this new feature. Where do I make a mistake ? |
This comment has been minimized.
This comment has been minimized.
To make this work, you have to change
The feature is strictly opt-in, as it is a) experimental and b) shall not change the behavior of already used scripts/executables without the user meaning to do so. Once this features isn't that experimental any more, I'll spread the documentation out to be more consistent with what's where. |
This comment has been minimized.
This comment has been minimized.
novazur972
commented
Nov 27, 2018
Le mardi 27 novembre 2018 à 00:18 -0800, Sven Eden a écrit :
To make this work, you have to change /etc/elogind/login.conf to
contain:
[Sleep]
#AllowPowerOffInterrupts=no
AllowSuspendInterrupts=yes
Ok !
The feature is strictly opt-in, as it is a) experimental and b) shall
not change the behavior of already used scripts/executables without
the user meaning to do so.
I understood that.
(That's also the reason why I have "hidden" the documentation a bit.
It is in the loginctl man page under "Hook directories")
Once this features isn't that experimental any more, I'll spread the
documentation out to be more consistent with what's where.
Thanks
|
This comment has been minimized.
This comment has been minimized.
novazur972
commented
Nov 27, 2018
Works nicely for me.
Thank you. |
metafarion commentedAug 7, 2018
I'm trying to make use of the sleep hooks placed in /lib/elogind/system-sleep to prevent the system from suspending under certain conditions, but unlike pm-utils, elogind doesn't seem to care if a pre-suspend script exits with code 1. What is the proper way to conditionally interrupt automatic suspend?