How to prevent suspension when a program is currently running?

Solution 1:

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.

sudo add-apt-repository ppa:caffeine-developers/ppa && sudo apt-get update && sudo apt-get install caffeine && sudo apt-get install gir1.2-appindicator3-0.1 gir1.2-notify-0.7

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

enter image description here

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.

Solution 2:

How to disabled the Suspend function, even if a program is running or not:

You have to goto the System Configuration and then click on Energy option. Now you should see an image similar than this one: energy

Then you will see the option called Suspend when inactive for and put this one on Don't Suspend, as you see on the previously image.

Solution 3:

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.

while true; do xdotool mousemove_relative 0 0 && sleep 30; done

In short, what keeps your computer "alive" is the INPUT events.