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.

  • 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 '12 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 '12 at 14:10
  • Which GNOME are you using? GNOME 2 or 3?
    – fpmurphy
    Apr 15 '12 at 16:35
  • Gnome 3.2 on F16
    – davefiddes
    Apr 15 '12 at 21:19

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.

  • 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 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 at 0:59

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.)

  • 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 '12 at 21:19

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:



After that, just use the following wrapper:

test -z $MAKEPRG && export MAKEPRG=$(which make)
    $MAKEPRG $@

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
    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 '12 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 '20 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.