18 November 2016

Screensaver on, CPU goes quiet.


While that would be nice for a Desktop PC that is not running services or things alike, it is far from true.


If you don't believe me open the CPU monitor and then this page
https://people-mozilla.org/~jmuizelaar/fishbowl/fishbowl-gl.html

You will see the CPU utilization going up (unless you have a very good machine).
When the screensaver is activated that CPU usage does not go down. Only the sound gets stopped.


Recently I am being a big 'performance paranoid' and have done a few things like:

- change ext4 and mount (fstab) options to improve performance / reduce unnecessary i/o
- remove unnecessary services

Now I am with the CPU.
So I created an script that reacts to screensaver changes and basically stops/starts all the browsers (the hungry CPU eaters on my PC). As simple as that.

Most of the script comes from within the manual xscreensaver-command
# man xscreensaver-command


Here is the full script (I used "# tail -f" on a text file during testing to verify it was working, plus looking at the CPU graph).


---------------

#!/usr/bin/perl

               my $blanked = 0;
               open (IN, "xscreensaver-command -watch |");
               while (<IN>) {
                   if (m/^(BLANK|LOCK)/) {
                       if (!$blanked) {
                               # que hacer
                           #system "sound-off";
                            system "killall -s STOP iceweasel chromium firefox";
                            #system "echo 'stopped all' >> /home/xx/tmp/sss";
                            #system "date >> /home/xx/tmp/sss";


                           $blanked = 1;
                       }
                   } elsif (m/^UNBLANK/) {
                               # que hacer
                               #system "sound-on";
                            system "killall -s CONT iceweasel chromium firefox";
                            #system "echo 'started all' >> /home/xx/tmp/sss";
                            #system "date >> /home/xx/tmp/sss";


                       $blanked = 0;
                   }
               }


---------------


0 Comments:

Post a Comment

<< Home

Too Cool for Internet Explorer