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.


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


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

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.


LightsOn script

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 “’ script in your Home folder. Whenever you want to run it, simply use the command:

./ 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 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?


Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox