Prevent Ubuntu From Going to Sleep While Watching Video

It can be pretty annoying when the screensaver pop in to take over the screen while you were watching video. In Mac, you can easily prevent the screen from sleeping, either with a command or with the Caffeine app. What if you are using Ubuntu? What solutions do you have to prevent the screen from going to sleep, or even dimming down?

Yes, this app has the same name as the Caffeine app for Mac. No, they are not by the same developer and company even though they are similar in functionality. This Caffeine app is a lightweight system tray application that temporarily prevent the screen saver and power saving mode from activating.

Installation

In Ubuntu, you just have to open a terminal and type the following command:

sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine

Usage

After the installation, you can launch the application and it will show up in the system tray. The usage is very simple. When you are watching a video, simply click on it and select “disable screensaver”.

caffeine-disable-screensaver
even
If you head to its Preferences page, you can even add certain programs, like VLC, to the list so that it is activated automatically when those apps are running. You can add activate it for Flash video or Quake Live.

caffeine-preferences

Unless the Caffeine app, the LightsOn script is a script that you have to run manually. By default, it checks Mplayer, Minitube and VLC to see if it is playing any video, and Firefox or Chromium whether it is running flash video full screen. When the check returns true, it will disable the screensaver and power management so it won’t go into sleep or dim the screen brightness.

There is no installation required. All you need to do is to download the script from its Github page and place the “lightsOn.sh’ script in your Home folder. Whenever you want to run it, simply use the command:

./lightsOn.sh xx

where “xx” is the time in seconds that you want the script to check for active video or full screen mode.

The difference between Caffeine and LightsOn.sh is that Caffeine detects application by its process ID while LightsOn checks for the window class. In addition, Caffeine is activated when the app is running (regardless whether it is playing video, or in full screen, or not) while LightsOn is only activated when it detects the application AND it is running in full screen mode. Nevertheless, they have the same functionality.

Note: Ubuntu doesn’t come with any screensaver installed, so LightsOn will show a “No screensaver detected” message. It will still work to prevent the power management to step in.

What other ways do you use to prevent your Ubuntu from going to sleep?