The screensaver / lock screen isn’t temporarily disabled when playing videos in some applications or in a web browser which can be very annoying, so here are two ways to inhibit the screensaver while watching videos.
Caffeine is a small tray / indicator app that automatically inhibits the screensaver / sleep powersaving when certain programs are running, which works with both GNOME Screensaver and Xscreensaver.
You probably already know Caffeine (we’ve covered it before
), which means you might know that it doesn’t work with some Flash websites such as YouTube or HTML5 videos. But you can configure it to automatically disable the screensaver when a certain process is detected from its preferences: click “Add”, then add the processes you want, like “vlc” for instance:
This way, you can add “firefox” for instance (alternatively, you can add “plugin-container” to only disable the screensaver when Flash is running) or “chromium-browser” so when one of these browsers is running, the screensaver is temporarily disabled. Of course, this is not perfect since the screensaver is disabled while the browser (or when VLC, etc.) is running and not only when playing a video in full-screen and this is why there are two ways of temporarily disabling the screensaver in this post.
To install Caffeine in Ubuntu, use the commands below:
sudo add-apt-repository ppa:caffeine-developers/ppa sudo apt-get update sudo apt-get install caffeine python-glade2
For other Linux distributions, you can get Caffeine via Launchpad.
lightsOn.sh is a script that works with Firefox and Chromium browsers which initially worked with xscreensaver and kscreensaver and only for Flash. I’ve modified the script to support gnome-screensaver and HTML5 too (well, sort of).
The script tries to detect when playing a Flash video in full-screen and inhibits the screensaver. It also detects when the browser window is in full-screen and when this happens, it prevents the screensaver from activating – I’ve added this to get it to work with some Flash websites and HTML5 videos but unfortunately, it also means that the screensaver will be disabled if you regularly use Firefox or Chrome in full-screen. But if you don’t like this behaviour, it can easily be disabled (in the script, change the “html5_detection” value from 0 to 1). If you find a better way to get the script to work with HTML5, let us know in the comments!
So the difference between this script and Caffeine is that the script temporary disables the screensaver only when a Flash video or the browser window is in full-screen while Caffeine disables it when a certain process is detected, no matter if you’re actually watching a video or not.
To download the script in a folder called “scripts” in your home directory and make it executable, copy/paste the commands below in a terminal:
mkdir -p ~/scripts && cd ~/scripts wget https://raw.github.com/hotice/lightsOn/master/lightsOn.sh chmod +x lightsOn.sh
Or download the script from HERE.
By default, the script works with Firefox and Chromium, but you can also enable it for VLC or mplayer. To do this, open the “lightsOn.sh” file and modify the “mplayer_detection” and/or “vlc_detection” from 0 to 1.
To run the script, use the following command:
To get the script to run each time your computer starts, you can add it to the startup applications – to do this, open “Startup Applications”, click “Add”, under “Name” enter “lightsOn” (or whatever you want), then click “Browse” and select the “lightsOn.sh” file from the scripts directory which you should find in your home folder.