Linux Kernel Source Code Screensaver

 screensaver

On Ubuntu, here’s how you install the phosphor screensaver:

sudo apt-get install xscreensaver-data-extra

Next we need to make sure that the Linux source code is installed on our system. Chances are your kernel source code will be installed in the /usr/src directory. If it’s not installed there, check with whoever maintains your distribution of Linux to find out where they keep it. Here’s how to install the source package on Ubuntu:

cd /usr/src
sudo apt-get install linux-source
sudo tar -xpjf linux-source-2.6.22.tar.bz2
sudo ln -sf linux-source-2.6.22 linux-source

Now, we need to feed the source code into phosphor. It was quite simple to write a command to fetch the code: cat `find /usr/src/linux-source/ -name ‘*.c’` The problem was it was giving me the same code in exactly the same order every time. I needed a way to get the find command to give me the files in a completely random order so that the screensaver was different every time. After extensive research, I discovered that find does not have an option for this. I could not find any command line utility for doing this either. So, I wrote one myself. It’s really simple and I plan on expanding it in the future, but it works perfectly for this project. It’s called Argument Shuffle. Just follow the instructions on that page for installing it.

Now we’re ready to put it all together. Go into your screensaver preferences, and go into the phosphor setup. You can set up the speed, scale and fade settings however you like. The important part is the “text program” box. Here’s the command:

cat `find /usr/src/linux-source/ -name ‘*.c’ | argshuf`

Note the backquotes! That command will find all of the files in the Linux kernel source directory which end in .c, and it will then pick one of those files at random and dump its contents into phosphor. This command is pretty tweakable, if you want to mess around with it. If you want to display .c files and .h files, then change it to: cat `find /usr/src/linux-source/ -name ‘*.c’ -or -name ‘*.h’ | argshuf`. If you wanted to display only .c files that are bigger than 100k, change it to: cat `find /usr/src/linux-source/ -name ‘*.c’ -size +100k | argshuf`. You get the idea. Read more about find if you want to do something specific. Enjoy!

Here are a few screenshots:

One thought on “Linux Kernel Source Code Screensaver”

Comments are closed.