SDL Saver

Other stuff I've written.

SDL Saver is a patch for xscreensaver to provide a hack which permits you to run mostly any SDL program as your screen saver. In addition to providing the support for running SDL programs, you may use any software that allows its X11 window id to be defined. With SDL the mechanism used is the SDL_WINDOWID environment variable.

Download

SDL Saver ver 2: patch against xscreensaver 4.24

Installing to a Debian/Ubuntu system

Here's how to install the patch to a Debian/Ubuntu system.

wget http://modeemi.cs.tut.fi/~flux/xscreensaver-4.24-sdlsaver-ver1.patch
apt-get source xscreensaver
sudo apt-get build-dep xscreensaver
cd xscreensaver-4.24
patch -p1 ../xscreen*.patch
./configure
make
sudo install hacks/sdlsaver /usr/lib/xscreensaver/sdlsaver 
sudo install -m 644 hacks/config/sdlsaver.xml /usr/share/xscreensaver/config/
echo 'xscreensaver*programs: sdlsaver' | xrdb -merge
xscreensaver &

Not click settings open, or if you miss the opening dialog, run xscreensaver-demo. Configure the saver with the appropriate binary/shell script.

Of course, you could just build the binary sdlsaver and copy it with the configuration file sdlsaver.xml to the appropriate directory.

Usage

Use xscreesaver-demo to switch to SDL Saver. Configure the program parameter. If you need to pass custom parameters to it (the parameter entered is the binary name, nothing else), use a shell script. Sorry, this is a crude one-evening hack.

You may use any program that can be fed the X11 window id as a parameter. Simply write a shell script that takes the environment variable SDL_WINDOWID and passes it down to the actual program. See below for an example.

Note: in the script, it is important to handle SIGTERM properly. Most often this is easily done by execing the final program to run!

Playing videos

I personally run a shell script doing the following shell script as my screensaver:

#!/bin/sh
exec /usr/bin/mplayer -loop 0 -fs -vo sdl ~/X/ombpes.mov >/dev/null 2>/dev/null </dev/null
    

At this point someone might notice "Hey, why did you make this SDL-specific at all, why not just provide the display as an argument to the shell script you're bound to write anyway" (or use a format-string kind of approach), and rightly so. Reason: I first hacked it to work with SDL and didn't want to redo it, managing patches is a bother. It's a screensaver!

Running any piece of software

Here is a shell script I used to run custom programs as the screen saver binary:

#!/bin/sh
trap 'kill $xpid' TERM
Xephyr -noreset -once -ac -parent $SDL_WINDOWID :1 &
xpid=$!
sleep 1
export DISPLAY=:1
xlock -geometry 512x384+0+0 -nolock -inwindow -mode ifs &
xlock -geometry 512x384+512+0 -nolock -inwindow -mode ifs &
xlock -geometry 512x384+0+384 -nolock -inwindow -mode ifs &
xlock -geometry 512x384+512+384 -nolock -inwindow -mode ifs &
wait
    

Erkki Seppälä
Last modified: Mon Feb 18 14:01:48 EET 2008