Use Linux OS suspend inhibitors to avoid standby #4049
Closed
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.
On linux hosts, AvoidStandbyService checks for executables
gnome-session-inhibit and systemd-inhibit in that order, then starts
the first found to prevent suspend or sleep while Bisq is running.
Although the hide avoid standby mode button is not displayed on linux,
the inhibitors can be toggled off/on when and if that button is
displayed. An installed shutdown hook will turn the inhibitor off,
but they should always die when the parent process dies.
To check when an inhibitor is enabled or disabled from a linux terminal:
If neither gnome-session-inhibit nor systemd-inhibit are present, the
standby service falls back to playing the silent audio file.
This does not cover all linux desktop types, but other inhibitors
exist for desktops I have not set up, such as mate, and it will not
be difficult to make changes to support them.
Memory use reduction varies from machine to (virtual) machine, but on my
Ubuntu 18 laptop, playing the audio file to block suspension is allocating
about 1 GB of native memory per hour -- via malloc() -- which this PR elminates.
On the same machine, virtual memory use goes from 10.4 GB to 10.1 GB.
This has been tested on Ubuntu 18 (gnome) and the following VMs:
But, VMs not running an inhibitor or audio file did not always go into suspend mode
as expected.
This does not work on Windows Cygwin, but minor changes might make it work if
cygwin inhibitor tools like gnome-session-inhibit.exe and mate-session-inhibit.exe
are installed.
Addresses native / virtual memory allocation issues.
Fixes #replaceWithIssueNr, fixes #replaceWithIssueNr
Your PR description here.