this is a short manual how to fix the behaviour of the screensaver in Linux Mint 11 (or any other distro using Gnome 2.x as a Desktop manager)

What is the problem? The screensaver in plain Linux Mint 11 is not deactivated when you play a movie with 'vlc' or a flash movie in Firefox. That is a little annoying because the screensaver will blank your screen while you are watching the movie. Of course you could just switch the screensaver off but then the screen and computer stays awake even if you fall asleep... This is not what you want.

There is a way how to handle this stuff nicely but not all applications make use of this possibility. Fortunately the default movie player Totem does it right. It inhibits the screensaver when you start playing something (movie, audio) and it uninhibits the screensaver when it is finished playing your media. But there are a great number of players / processes that do not make use of the possibilities of the gnome-screensaver (yet).

This is where my little script comes in. It is not very sophisticated and it does not make use of the official way to handle (un)inhibiting the screensaver via the Dbus but for me it works great at the moment and perhaps someone is happy with it. I will test it some more days and perhaps after that I will rewrite it so that it uses the official way of doing things.

What the script does is the following. It checks whether some predefined processes eat up too much CPU and decides whether this should (un)inhibit the screensaver. The processes can be defined in the script itself in the following section:

What you see here is that the screensaver will be inhibited when firefox eats up 50% (or more) of the CPU (which most certainly means that I am watching a movie in HTML5). It also inhibits the screensaver if the plugin-container uses more than 15% of the CPU which most certainly means I am playing a flash video and so on.

Of course, this is based on assumptions and it will not be the same for every system but I found that I can make a 100% matching profile for my own computer which is great. The screensaver does exactly what it should do. Keep quiet when I am watching a movie and kick in afterwards. That's great!!

There is another problem. If one undefinded process is making heavy use of the processor, the defined processes could stay below their thresholds because looking at the percentages the processes seem not very busy even if you are watching video. That's why I added the possibility to inhibit the screensaver when the total load of the system gets "very high" as well. You can adjust this in the following part of the script:

You can and should edit those parts of the script to match your needs. Additionally, if you want to inhibit the screensaver while a lengthy operation is going on on your system, just add a line to the processlist with the appropriate CPU usage. In fact it is quite easy to get the script right with some Linux experience.

You can get the whole script below.

Play around and get the parameters right for your needs. (Yes, this could be a hard part for Newbies, just ask if you do not know what to do)

After that add it to the startup items of your Gnome desktop.

And then you will never have to wiggle the mouse again to keep watching your Flash movie in Firefox.

Have fun and take care!

Magnetizer-----

Here is the whole script (tried to add it as an attachment but to no prevail):

# ====================================================================## screensaver_inhibitor -- script to (un)inhibit the screensaver due# to the CPU usages of several predefined# processes and the total system load.## Usage: screensaver_inhibitor## Author: <magnetizer@live.com>## written on 10/08/2011## Copyright: Magnetizer, october 2011## ====================================================================

It got much simpler by making use of the 'dbus-send' command and it's a lot nicer because it doesn't kill processes just to start them again, which was kind of quick and dirty.

There are still some improvements I could make:

1) Making use of Net::DBus instead of a system call via 'dbus-send'. The script could then be run by 'cron' instead of being a continous process with a 'sleeptime' after each iteration. That would be nicer but I think it is not really necessary.2) I could use the 'Inhibit' / 'Uninhibit' methods instead of 'SimulateUserActivity'. I think this is what they are for. But then this would mean that the script gets more complicated again, so why bother? 3) Find a way to be sure that flash is playing a movie. Right now, I use the CPU usage of the flash plugin to make that decision but this could give false positives / negatives. The problem is, not all flash videos use the same amount of the CPU, it depends on the site you are on. In principle this could mean that the script does not work correctly on some sites.

But anyway, I use the script for several days now and it works nicely for me.

# ====================================================================## screensaver_prevention -- script to prevent the screensaver due# to the CPU usages of several predefined# processes and the total system load.## Usage: screensaver_prevention## Author: <magnetizer@live.com>## written on 10/08/2011## Copyright: Magnetizer, october 2011## ====================================================================

I am also looking into ways to diffenrentiate between deactivating the screensaver or deactivating the sleep mode. This could be useful when performing a lengthy operation such as backups or calculations. In that case the screensave may show up and lock the screen but the computer is not supposed to go into the sleepmode.

here is another update of the script that automatically disables / enables the screensaver according to userdefined conditions (CPU usage of processes). The script now only checks for the processes of the current user. That means that if someone else is logged in the screensaver will not be inhibited.

I have also created a little app for the notification area. It does the same thing but you can also click on it to disable / enable the screensaver manually. I use this all the time now and it works great. I have written this app for Ubuntu but as Mint also uses Gnome 3 en GTK, I suppose it should also work with Linux Mint.

If someone wants to try it, let me know in this thread and I will post it.

it looks like you have entered "0,0" somewhere as a threshold for a process. The right notation would be "0.0" or even "0". That should solve the error message but it is not very useful to enter a threshold of "0%" for a process. This would mean that your screensaver will be inhibited all the time, which is the same as turning it off completely.

# define total load that will inhibit the screensavermy $maxLoad = 10;

---------

I am finishing a new version of an even nicer program to deal with the same problem. It will give you a little inidicator in the panel showing whether your screensaver is switched off or on. You can use it in the same automatic way as this script, but you can also click on it to switch the screensaver off manually.

I wrote this script for Linux Mint 11. It did a fine job, but things have changed in the meantime. I will post a greatly improved script within the next days which I am developing for Linux Mint 14. I will gladly explain how to use it. No worry, it is quite easy...

here is the newest screensaver inhibitor script. You can use it to automatically inhibit your screensaver when some important process is running. For instance, you can automatically disable the screensaver while watching video in your browser or while you are backing up files or some other lengthy process.

The script gives you a little app in the taskbar showing if the screensaver is disabled by the script or not. You can also use this icon to manually disable the screensaver or to pause the program.

The app deactivates the screensaver nicely while watching a (Flash) video, afterwards it activates the screensaver again. If there is no user interaction at all, something strange happens. The screensaver starts after a while but then the screen comes back to life and stays on even though the screensaver is not blocked by the script. One jiggle with the mouse and everything works fine again.

This is rather strange and till now I have no idea where to look for the bug. As a workaround I tried to simulate some user activity to reset everything to normal but that does not do the trick. If you watch a movie and afterwards use your computer again, you will not encounter this bug. It only happens if there is no user activity at all.

here is the newest version of this script. I fixed a minor bug. The icon will now update immediately if the app is changed from any status to "automatic".

I also added "vlc" to the list of predefined processes as there is an annoying bug in vlc: Vlc does correctly inhibit the screensaver but it does not reenable it after after the video is finished or when the video is paused. This means the screensaver will not kick in after you have watched the movie.

I fixed this behaviour by:

1) adding "vlc" to the script with a threshold of 10% CPU usage2) changing the "advanced preferences" in vlc: * Start vlc * Click on Tools --> Preferences --> Show settings All * Uncheck "Inhibit the power management daemon during playback"

Now vlc will not disable the screensaver at all, but that's ok as the screensaver inhibitor applet will take care of this.

I don't knwo, usually when I am using the computer (running a session), I don't want any screensaver interruptions at all..

http://www.webupd8.org/2012/05/2-ways-t ... sable.html--various tricks/scripts to get around screen saver issues: I think it is so much simpler to just turn off screen saver while at work..So, I might may that step one: disable screen saver on the available settings menus screensavers selection(s)

I don't knwo, usually when I am using the computer (running a session), I don't want any screensaver interruptions at all..

http://www.webupd8.org/2012/05/2-ways-t ... sable.html--various tricks/scripts to get around screen saver issues: I think it is so much simpler to just turn off screen saver while at work..So, I might may that step one: disable screen saver on the available settings menus screensavers selection(s)

Thanks, nice to hear that the script is useful for others aswell. I think the reason why it is no default behaviour is because it is not really a "ready out of the box" solution. It still needs some fiddling but then it works great.