Thursday, December 22, 2005

Linux screensaver for Windows

Construct and package a Linux® LiveCD so that it will install using the standard Microsoft® Windows® install process and will operate as a standard Windows screensaver. Answering the most common concern about open source software, this article shows that, yes, Linux will run under Windows.

So why should you read this article? Why, indeed, should I write it? My motive is to help remove two obstacles to the wider adoption of free and open source software. Those obstacles are:

Most computer users are familiar with a Microsoft Windows environment and with the variety of screensavers available to prevent unauthorized access to the data on the computer when unattended.

There is sufficient free and open source software available nowadays to enable Linux to install and run as a Windows screensaver. This article shows you how to construct an appropriate CD or DVD, and in doing so, demonstrates that the "free" and "non-free" sides of the software Grand Canyon are not so far apart after all.

The examples in this article correspond to three current IBM objectives:

Successor to OS/2

OS/2 is finally being withdrawn on December 23, 2005. According to the IBM Web site on OS/2 Warp migration (see Resources), there is no replacement product from IBM. IBM suggests that OS/2 customers consider Linux.

But which Linux? Without knowing what a client intends to do, it would be irresponsible to make a blanket recommendation. However, on December 25, 2005, the demand for GamesKnoppix St. Nicholas' Day will be large, and the delivery capability will be sufficient. And if you configure it as a screensaver, even the possibility of pressing the wrong key to start it is eliminated.


Figure 1. GamesKnoppix St. Nicholas' Day
GamesKnoppix St. Nicholas' Day

The base ISO is GamesKnoppix 3.7-0.1 (see Resources).



Back to top


Reinventing education

Reinventing education is a central focus for IBM's philanthropic efforts -- but even IBM is limited in what it can give. Organizations chartered with this task -- such as the United Nations Educational, Scientific, and Cultural Organization (UNESCO) -- use all their resources to that end. UNESCO has co-branded with the Organization for Free Software in Education and Teaching, a group of concerned French parents, resulting in a "UNESCO Linux" (look for the Freeduc-CD). The license model for it is clear -- they accept donations and they give it away for free.

Again, configuring the UNESCO Linux as a Windows screensaver eliminates fear, uncertainty, and doubt.


Figure 2. UNESCO Linux/Freeduc-CD
UNESCO Linux/Freeduc-CD

The base ISO is freeduc-cd 1.4.1 (see Resources).



Back to top


Enabling science

Enabling scientific research and progress is another pillar of IBM's philanthropic efforts -- without this particular effort, there might be no future IBMers (or future clients). But Big Blue cannot be everywhere. That's why there is Knosciences.

This Linux screensaver is from Nathalie Carrie and Arnaud Verhille, science teachers on Reunion Island, a French colony in the Indian Ocean. This screensaver comes equipped with 700MB of applications to help school children learn their math and physics. Verhille asks "Does anyone know where I can get a free Java," because he is concerned about encumbering his pupils with Sun®'s license conditions.


Figure 3. Knosciences
Knosciences

I use Knosciences 0.95 in this article (see Resources).



Back to top


Making it work: Nuts, bolts, and screws

Getting the ISO to run under another operating system requires an open source PC emulator, which includes an open source BIOS and an open source virtual graphics adapter (such as QEMU version 0.7.2). The emulator enables you to set up a virtual PC within a real one. To construct a screensaver, the best way is to configure it with a virtual CD-ROM drive, keyboard, screen, and mouse, but without any virtual disks or network adapter.

Remember, running in emulation is slow (or "slooooooooowwww," like running interpreted Java code). But since we're doing this under the auspices of a screensaver, modern PC hardware is sufficiently fast for the task.

Here are the steps to make this work.

Rebuilding QEMU

You need to rebuild QEMU -- I learned how by following instructions in a QEMU forum (see Resources). Get these packages:

Inno Setup can help you package things in a way that is familiar to Windows users. I used version 5.1.5.

For a program to run as a Windows screensaver, it needs a name like "Knosciences.scr" and it needs to be in directory C:\WINDOWS\SYSTEM32\. It will start from the command line with a command like Knosciences.scr /s and its "current directory" will be C:\WINDOWS\SYSTEM32\.

With the following alterations to file vl.c in QEMU, it responds appropriately to the /s switch and runs in full-screen mode. This implementation removes the virtual network card; if you take out the line specifying the net_if_type, you will have a screensaver that treats Windows as a NAT-router-firewall.


Listing 1. Modifications to QEMU to enable it to run as screensaver


for(;;) {
if (optind >= argc)
break;
r = argv[optind];
if (r[0] != '-') {
if ( 0 == strcmp(r,"/s") ) {
/* Going to run as a Windows screen saver */
full_screen = 1 ;
bios_dir = "." ;
ram_size=512*1024*1024 ;
boot_device='d' ;
hd_filename[cdrom_index] = "knosciences-0.95.iso" ;
rtc_utc = 0;
net_if_type = NET_IF_DUMMY;
optind += 1 ;
} else {
hd_filename[0] = argv[optind++];
}
} else {
...
}
if ( full_screen == 1 )
{
putenv("SDL_VIDEODRIVER=windib") ;
}

After building QEMU, rename the i386-softmmu version of the qemu.exe file to Knosciences.scr.

Inno Setup

The following script for Inno Setup puts the screensaver and the ISO file into the C:\WINDOWS\SYSTEM32\ directory:


Listing 2. Script for the installer


; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
;

[Setup]
AppName=Knosciences Screen Saver
AppVerName=Knosciences Screen Saver
AppPublisher=OFSET
AppPublisherURL=http://www.ofset.org/
AppSupportURL=http://www.ofset.org/
AppUpdatesURL=http://www.ofset.org/
DefaultDirName={pf}\Knosciences
DefaultGroupName=Knosciences
Compression=lzma
SolidCompression=yes

[Files]
Source: "{src}\qemusaver\Knosciences.scr"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemusaver\knosciences-0.95.iso"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemu\SDL.dll"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemu\bios.bin"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemu\vgabios.bin"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemu\vgabios-cirrus.bin"; DestDir: "{sys}"; Flags: external
Source: "{src}\qemu\qemu-doc.html"; DestDir: "{app}"; Flags: external
Source: "{src}\qemu\vl.c"; DestDir: "{app}"; Flags: external
Source: "{src}\qemu\LICENSE\LICENSE"; DestDir: "{app}\LICENSE\LICENSE";
Flags: external
Source: "{src}\qemu\LICENSE\README-SDL.txt"; DestDir: "{app}\LICENSE\README-SDL.txt";
Flags: external
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\Knosciences Screen Saver"; Filename: "{sys}\Knosciences.scr"
Name: "{group}\{cm:UninstallProgram,Knosciences Screen Saver}"; Filename: "{uninstallexe}"

File structure for the CD

The following file structure is needed for the CD:


Listing 3. Bill-of-materials for the resulting CD


.
./autorun.bat
./autorun.inf
./autorun.pif
./qemu
./qemu/bios.bin
./qemu/linux_boot.bin
./qemu/qemu-doc.html
./qemu/qemu.exe
./qemu/qemu-img.exe
./qemu/qemu-knoppix.bat
./qemu/vl.c
./qemu/qemu-tech.html
./qemu/qemu-win.bat
./qemu/README-en.txt
./qemu/README-ja.txt
./qemu/SDL.dll
./qemu/vgabios.bin
./qemu/vgabios-cirrus.bin
./qemu/LICENSE
./qemu/LICENSE/LICENSE
./qemu/LICENSE/README-SDL.txt
./qemusaver
./qemusaver/qemusaver.iss
./qemusaver/Knosciences.scr
./qemusaver/knosciences-0.95.iso
./cdrom.ico
./SetupQemuSaver.exe
./Knosciences
./Knosciences/index.html
./Knosciences/knosciences-0.95.css
./Knosciences/knosciences-0.95.html
./Knosciences/labels.pl
./Knosciences/node1.html
./Knosciences/node10.html
./Knosciences/node100.html
./Knosciences/node101.html
..
./Knosciences/node97.html
./Knosciences/node98.html
./Knosciences/node99.html
./Knosciences/WARNINGS
./index.html

The autorun.bat file

The autorun.bat file (which is started when the CD is put in the reader/player) looks like this:


Listing 4. autorun.bat


@start SetupQemuSaver.exe
@start index.html
@cd qemu
@start /MIN qemu-knoppix
@exit

The qemu-knoppix.bat file

The qemu-knoppix.bat file (which starts the Knosciences demo as part of the autorun sequence) looks like this:


Listing 5. qemu-knoppix.bat


@echo off
REM KNOPPIX on Windows File System
REM Written by Japanese KNOPPIX TEAM 2004.08.17
REM Contact: knoppix@m.aist.go.jp
REM License GPL

REM If you get iso image of KNOPPIX, please use the following options.
REM Join the following two lines before running this bat file; it was split for space purposes.
qemu.exe -L . -m 128 -boot d -cdrom ../qemusaver/knosciences-0.95.iso -user-net -enable-audio
-localtime
REM ^^^^^^^^^^^^^^^^^^^^^^^^^^
exit

Shell to create the ISO image

The following shell function will create the ISO image. You can also create the CD under Windows; there is no requirement for the CD to be bootable.


Listing 6. Constructing the ISO image


function remaster_mkisofs
{
mkdir -p ${wrkdir}/new_iso
mkisofs -pad -l -r -J -v -V "Knosciences" -hide-rr-moved -publisher "OFSET http://www.ofset.org/" -p "http://www.ofset.org/" -volset "Knosciences 0.95 for Windows (knosciences 0.95 with QEMU 0.7.2)" -o ${wrkdir}/new_iso/freeduc.iso ${wrkdir}/files

}

That's really all it takes to install Linux from a LiveCD to run as a screensaver on a Windows machine. Have fun with it!



Back to top


Resources

Learn

Get products and technologies

Discuss


Back to top


About the author

Chris Ward

Chris Ward joined IBM from Cambridge University, England, in 1982. He has watched hard disks come and go. He has watched OS/2 come and go. He has seen both Windows and Linux come, and neither has gone yet. He has written about BlueGene/L for the IBM Journal of Research and Development. And he will invent and create anything for any commercial client of IBM or any charity or school supported by IBM's On Demand Community. Contact Chris at tjcw@uk.ibm.com.




source:http://www-128.ibm.com/developerworks/linux/library/l-scrnsave/


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?