[bisq-network/bisq] Use Linux OS suspend inhibitors to avoid standby (#4049)

Stan notifications at github.com
Wed Mar 11 15:05:40 UTC 2020


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 the desktop is gnome...

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

	If Bisq falls back to systemd-inhibit on a non gnome desktop...

	$ systemd-inhibit --list
	$ systemd-inhibit --list | grep Bisq

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:

	Debian 10.3 (gnome)
	Arch Linux 9.2.1 (gnome)
	Fedora 31.1.9 (cinnamon)

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.

<!-- 
- make yourself familiar with the CONTRIBUTING.md if you have not already (https://github.com/bisq-network/bisq/blob/master/CONTRIBUTING.md)
- make sure you follow our [coding style guidelines][https://github.com/bisq-network/style/issues)
- pick a descriptive title
- provide some meaningful PR description below
- create the PR
- in case you receive a "Change request" and/or a NACK, please react within 30 days. If not, we will close your PR and it can not be up for compensation.
- After addressing the change request, __please re-request a review!__ Otherwise we might miss your PR as we tend to only look at pull requests tagged with a "review required".
-->

Fixes #replaceWithIssueNr, fixes #replaceWithIssueNr

Your PR description here.

You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/4049

-- Commit Summary --

  * Use Linux OS suspend inhibitors to avoid standby

-- File Changes --

    M core/src/main/java/bisq/core/app/AvoidStandbyModeService.java (105)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/4049.patch
https://github.com/bisq-network/bisq/pull/4049.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4049
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200311/595c70ce/attachment.html>


More information about the bisq-github mailing list