The screensaver plugin runs inside freevo and starts a ScreenSaverPlugin after it has detected a configurable period of inactivity.
To activate the screensaver plugin add the following lines to your local_conf.py
SCREENSAVER_DELAY = 300 # of seconds to wait to start saver. SCREENSAVER_CYCLE_TIME = 60 # of seconds to run a screensaver before starting another saver. plugin.activate('screensaver')
The screensaver plugin is in fact just the framework to start the ScreenSaverPlugins, with just the line above you would get no pretty screensavers just a black screen.
To activate any number of plugins (they are picked at random and changed after SCREENSAVER_CYCLE_TIME) add the following lines to your local_conf.py
plugin.activate('screensaver.balls') # Bouncing balls all over the screen plugin.activate('screensaver.bouncing_freevo') # The freevo logo bouncing around the screen
Writing your own screensaver
ScreenSaverPlugins are very simple to write (if you want an example take a look at plugins/screensaver/bouncing_freevo.py).
def start(self, width, height): """ Initialise the screensaver before each run. Returns the number of frames per second the saver wants to run at. """
The start() method is called when the screensaver is about to start running and should return the number of times a second the draw() method will be called. For reasonable smooth movement with out taxing the processor too much 15 fps is a good value.
def stop(self): """ Deinitialise the screensaver after each run. """
The stop() method is called when the screensaver is no longer needed and allows the plugin to release any resouces it was using.
def draw(self, surface): """ Draw a frame onto the supplied surface called every 1/fps seconds (where fps was returned by start()) """
The draw() method is the central method that is called continously while the screensaver is active. This method should update the surface passed to it (which won't be cleared between calls) using pygame primitives and return. The framework handles the fliping of the surface to the screen.