The beforelight program is a sample implementation of a screen saver for X servers supporting the MIT-SCREEN-SAVER extension. This is from the modular X.org X11 project.