Inhibit suspend during the processing of an imaging operation #1251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a direct response to a poor user experience I had with the tool. Per issue #1188, I set up an operation to download & write an image to a Micro SD card, and then I left the system doing its thing. When I returned, I found out that the system had deemed itself idle and gone to sleep after 15 minutes, long before the download completed.
This PR aims to address this by leveraging OS-specific functionality to inhibit autosuspend.
ES_SYSTEM_REQUIRED.PreventUserIdleSystemSleep.org.gnome.SessionManager. If this succeeds, it makes a call to theInhibitmethod.systemd-inhibit.kde-inhibit.These
-inhibitutilities in the Linux-specific side work by taking a command and executing it in a scope that inhibits whatever action is to be inhibited. The inhibition remains in effect until the process exits. In order to invert this control mechanism, the code here creates a FIFO and then has the command in the-inhibitscope read from it. It can then terminate the read at any time by closing its end of the pipe.Any errors are silently ignored; a best effort was made but if it can't explicitly inhibit suspending, we still want to perform the download & write operation.