Ubuntu – How to prevent suspension when a program is currently running


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.

Best Answer

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.


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.