Cool linux screensaver

Now I like a good screensaver and phosphor (written by Jamie Zawinski) is one of them. Phosphor emulates an old green monochrome terminal screen with a very long afterglow (due to the phosphor). Phosphor can be used in many ways. You can configure it to get its output from a file, URL or from a program. It can even emulate a VT100 so you can use terminal control characters. You could recreate some visicalc screens and old stuff like that, whatever keeps you ticking.

Now Jason Kress thought that it might be cool to display random Linux kernel source files using the phosphor screensaver and I like that. Jason created a small C-program to select a random file from all .c files found using the find command. I don’t like the fact that find has run to completion before a file is selected. Please keep in mind that the linux kernel has well over 9000 .c files. When I start my screensaver I’m taking a break. Possibly because my computer is compiling. I don’t want the screensaver hamper my compilation with a heavy find command on the disk.

So forget about Jasons solution. I created my own which uses a small shell script that creates a somewhat larger Perl script but it doesn’t require find at runtime anymore. How about that? The code to efficiently read a random line from an input source is straight from the Perl Cookbook. Here’s the small shell script. I called it but you can name it whatever you like. By the way I installed this in /usr/src

#!/bin/sh     # script to create
linux_src_dir=/usr/src/linux    # location of kernel src

cat << EOF > "$file"
rand(\$.) < 1 && (\$line = \$_) while <DATA>;
print \$line;
find -L "$linux_src_dir" -name \*.c >> $file
chmod 555 $file

So copy & paste the above script and save it in a text-file somewhere. Change the file if needed. You can change the definition of to rename the generated script. You can change the definition linux_src_dir=/usr/src/linux to indicate where your linux kernel sources are. When you are done changing the scripts to your preferences make the script executable and execute it.

Now you will have a generated perl script that contains all .c files in the specified linux source directory and randomly selects one without going through the linux source directory all the time. This saves you a lot of time and computing and disk I/O when the screensaver selects a random file. However you do need to remember to regenerate that script whenever you upgrade your linux kernel or else you may miss new files (and get errors on removed files). Now in my setup the generated perl script lives here: /usr/src/

Now you can configure your phosphor screensaver like this:

Phosphor settings

Mind the backticks. Whenever one file is done a new one is randomly selected. Enjoy. NERD!

Screenshot of screensaver in action

13 Responses to “Cool linux screensaver”

  1. fd0 Says:

    Cool beans :-)

  2. Sander Says:

    Een van mijn toppertjes op screen save gebied:

  3. Nikesh Says:

    Crap, I don’t see the “dump Pipe” and “Text program” text filed in OpenSuse 10.3, I guess they have removed this,

  4. Nikesh Says:

    Thanks, I just latest xscreensaver package with the older one, Now working fine

    Thanks Man :)

  5. Chad Jorgenson Says:

    So in Fedora 8 (and I bet Fedora 7) and presumably in Suse 10.3 from the reference above, the config file (/usr/share/xscreensaver/config/phosphor.xml in Fedora 8) for phosphor has some lines commented out:



    <!— –>

    So if we change it to look like below

    I see the new options when I go to reconfigure my screensaver.

  6. Chad Jorgenson Says:

    Well, so this forum engine doesn’t support the code comments I guess, but you should see some HTML comment tags in the phosphor.xml config file to comment out. Sorry..

  7. Benjamin Says:

    I don’t seem to have the “text program” box in my screensaver settings. Yeah the screensaver is installed, but theres only a bunch of unrelated settings.. Would it make a difference if i’m using Ubuntu 8.4, with the GDM screen manager instead of KDE?

  8. Eddie Niese Says:

    Benjamin said:

    I don’t seem to have the “text program” box in my screensaver settings.

    Please take the trouble to skim through other peoples comment before posting a question. Your question is already answered by Chad Jorgenson. Check the configuration file (phosphor.xml) of the screensaver.

  9. Otto Says:

    Very good! Thank you!
    I’ll modify and use in the work’s computer to print our project’s code :-)

  10. 文字檔內容作為螢幕保護程式畫面 « Jamyy's Weblog Says:

    […] BloggEd! – Cool Linux Screensaver […]

  11. Bunkai Says:

    I know this isn’t exactly a new post, but does anyone have any ideas why this hack will not work with the xscreensaver-gss version of phosphor?

    I’ve manually verified the create script, the contents of the .pl and the cat command and all were successful.

    I’ve edited /usr/share/applications/screensavers/xscreensaver-phosphor.desktop from this:
    Exec=/usr/libexec/xscreensaver/phosphor -root

    to this:
    TryExec=/usr/libexec/xscreensaver/phosphor -program ‘cat `/usr/src/`’
    Exec=/usr/libexec/xscreensaver/phosphor -root -program ‘cat `/usr/src/`’

    And now Phosphor doesn’t even show up as an option in my screensaver list. I revert it back to the original exec lines above and it shows up again.

  12. Bunkai Says:

    Sorry for the double post, but I just found another person’s modified desktop file that pointed me to the problem.

    The TryExec line should not have any arguments on it, only the Exec line. This is what those two lines now look like for me and it’s working great:

    Exec=/usr/libexec/xscreensaver/phosphor -root -scale 2 -ticks 13 -program ‘cat `/usr/src/`’


  13. abdo Says:

    thanks you brother,that i was looking for

Leave a Reply