Is there any way to make Ubuntu 12.04 understand when it should suspend or not in terms of the software that is currently running?
For example, if I am installing something and it takes more than 10 minutes, which is the time limit for my PC to suspend, then I do not want my system to system to suspend till the installation of the program is finished. If my system is inactive I want it to suspend,but on the other hand if something is running I do not want to suspend.
A relatively simple way to do it is by installing a program called caffeine. You'll need to add the repository then install it. For example, via the terminal.
(N.B. you'll need gir1.2-appindicator3-0.1 and gir1.2-notify-0.7 at the moment due to a bug in defining its dependencies.)
Once you have it installed and running, it should create an entry in the menubar or panel. You can manually prevent suspension, or set caffeine to activate automatically based on what processes are running. In your case, you can whitelist the installation program, such as
apt-get
. (I'm not sure what that is specifically, since you didn't provide the details.)N.B. I'm using Kubuntu, where it works well. It should also work in Unity.
Update
New versions of caffeine have been crippled, and much of this functionality has been removed.. I think the old version (2.5) still works, though, so you can try that.
How to disabled the Suspend function, even if a program is running or not:
You have to goto the
System Configuration
and then click onEnergy
option. Now you should see an image similar than this one:Then you will see the option called
Suspend when inactive for
and put this one onDon't Suspend
, as you see on the previously image.I do solve such things automating keyboard or mouse with xdotool package, using it in a dead-simple loop inside a terminal.
Is known that there are other software alternatives that send keyboard key F13 as non-intrusive alternative because that key exists but is not truly present for us.
You can send relative mouse movement with 0 values, so the input is sent, but the mouse is not perturbed.
In short, what keeps your computer "alive" is the INPUT events.