Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  rozcietrzewiacz 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? –  fpmurphy1 Apr 15 '12 at 16:35
    
Gnome 3.2 on F16 –  davefiddes Apr 15 '12 at 21:19

2 Answers 2

up vote 6 down vote accepted

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

share|improve this answer
    
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:

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
share|improve this answer
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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