13

I am trying to build a custom kernel for my machine which is taking a long time to build (as expected). Is it possible to stop my GNOME desktop from suspending the machine until the compilation has completed and then have it suspend (assuming I'm away from the machine for the 30 minutes it would normally take).

I don't want to permanently disable suspend (which is easy to do via the system settings control panel but wastes power) but rather be able to specify (via PID?) my compile job and have the computer suspend when it finishes.

4
  • Have you checked that it does suspend while compiling? That would be really strange... It should only suspend when the computer is idle for a declared amount of time - which is not the case when you compile a kernel. Apr 15, 2012 at 14:06
  • 1
    Yep. Definitely suspends mid-compile and then resumes when I come back to the keyboard and wake it up. AFAIK GNOME is just using my presence at the keyboard/mouse to determine whether the computer is being used or not.
    – davefiddes
    Apr 15, 2012 at 14:10
  • Which GNOME are you using? GNOME 2 or 3?
    – fpmurphy
    Apr 15, 2012 at 16:35
  • Gnome 3.2 on F16
    – davefiddes
    Apr 15, 2012 at 21:19

5 Answers 5

11

You can disable inactivity timeout completely.

For example to disable the suspend timeout only for AC power, run

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0

I personally thinks its completely stupid having an inactivity timeout to suspend the computer, while its on AC power, by default and with no option for normal people to disable this.

2
  • To also disable auto-suspend on battery power, this works: gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0 Mar 17, 2021 at 16:28
  • 2
    While this answer will disable auto suspend for AC power, it also changes the timeout to 0. To preserve the timeout setting and simply disable the auto suspend, use gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing' source
    – curiouser
    Jun 12, 2021 at 0:59
9

I haven't got the time for all details now, but see the GNOME Power Manager's FAQ "How do I make my application stop the computer auto-suspending" which points to the Inhibit() and UnInhibit() DBus-calls.

A caveat: if the process calling Inhibit() exits, the inhibition is ended - dbus-send in a Shell script thus won't do, but some wrapper script (e.g. in Python) is needed.

(Edit This blog post contains a little more information, also a Python stub that could be useful.)

1
  • Looks like I'm going to need to write a bit of python to do the necessary inhibiting and watching of the build process. Hmm. Thanks for digging up the details.
    – davefiddes
    Apr 15, 2012 at 21:19
3

GNOME has developed a neat solution to this problem in the form of the gnome-session-inhibit utility. To use it you just add it before the long running command something like:

gnome-session-inhibit make

It is possible to have several inhibit sessions running at once if required. These can be listed by running gnome-session-inhibit -l. For more details see the man page.

-1

You can wrap the make command in your shell so that it temporarily deactivates the gnome autosuspend feature.

First, you need to find out how to activate/deactivate autosuspend via a command line. This is probably doable via gconftool-2. A little research and hacking with gconf-editor should help (I can't really help regarding that, I don't use gnome).

Then, wrap this in functions in your shell:

disable_autosuspend()
{
    ...
}

enable_autosuspend()
{
    ...
}

After that, just use the following wrapper:

test -z $MAKEPRG && export MAKEPRG=$(which make)
make()
{
    disable_autosuspend
    $MAKEPRG $@
    enable_autosuspend
}

The MAKEPRG variable is here to hold the path to the real make. The test is here in the case you want to reload your rc file.

You can also suspend via dbus immediately after the compilation stops:

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
2
  • 2
    Oh, well, using the link provided by sr_, you can write the enable/disable_autosuspend wrappers... Edit oh no, the process calling inhibit() must not exit...
    – user48678
    Apr 15, 2012 at 17:13
  • Downvoting because: "This is probably doable via gconftool-2. A little research and hacking with gconf-editor should help (I can't really help regarding that, I don't use gnome)." Jun 19, 2020 at 3:54
-1

Generate a 1-hour long blank video file and play it in a player that supports MPRIS2. You could generate a series of "videos" of different lengths and cue them in a playlist, to get the desired inhibit time.

It is not aware of any process that might outlive the inhibit deadline, but if you know roughly how long the process will take, you can probably ballpark it.

Alternatively, you can buy an inexpensive device called a "mouse jiggler". It looks like a wireless mouse receiver, but it simulates a mouse that jiggles every so often. Some models have a button to toggle the function.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .