Novell Home

HowTo: Create an X windows Start up Splash Window

Novell Cool Solutions: Feature
By Stomfi

Digg This - Slashdot This

Posted: 25 May 2005
 

StomfiLearning to use Linux at Home and Work
Welcome to my ongoing series of HowTo articles designed to help Linux newbies get comfortable with Linux. Before trying any of these HowTos, take a few minutes to study the prerequisites so you can hit the ground running.
--Stomfi

This howto shows you how to create a start up splash window which I have used for the Dyne:Bolic CD on the 'SCOOL project. However it can be used for other distributions and Windows managers, and I will cover how to make a similar splash screen work for a SUSE 9.2 X windows start up at the end of the article.

The splash screen below is for the 'Dynebolic 'SCOOL project. It has a general message, an animated graphic, and five action buttons. Three of the buttons set up preferences, one displays help and other documentation and the other launches the application and exits the splash screen. The screen can also be exited with the usual window decorations.

Runtime Revolution is the IDE used to develop the screens for the application. www.runrev.com.

Special Offer for Cool Solutions Readers: Free Copy of Runtime Revolution

The good folks at Runtime Revolution have extended a special offer to Cool Solutions readers to make it easier for you to implement the great ideas in Stomfi's articles. They are offering it for free to Novell customers who know the secret code. See this page for details.

The Linux shell tools are used to perform information processing.

This is the Application browser window showing the controls on the splash screen. Field 1 is the general message. The opaque property is set to false to let Image 1, the animated graphic, which is underneath it, show through it.

These are these controls for the DYBOOT card.

The DYNEST card is almost the same except the names of the first two fields are NLIST and NMSG.

These are the controls for the USING window.

This is the DYBOOT window. If no drives with at least 700MB of free space are found on the system a relevant message is displayed. I used 700MB because I didn't want to use up all the free space. If a suitable drive is found it is listed and a click on it launches the shell script which populates the drive with the Dyne:Bolic boot up files. The user can use this screen to restart the computer so that Dyne:Bolic can recognise the new boot folder, or they can close it and return to the splash screen.

This is the DYNEST window. It works the same as the previous window except for the size consideration.

This is the USING window. Depending on which button is clicked the window displays text files relevant to the button titles.

Now I shall list the scripts that make it all happen.

This is the script for the NEST button:

on mouseUp

   put ($HOME & "/bin/findnest.sh") into FNEST

   replace return with empty in FNEST

   put the shell of FNEST into GOTNEST

   if GOTNEST <> "FOUND"

   then

      put GOTNEST into field "NLIST" of card "DYNEST"

      go card "DYNEST"

   end if

end mouseUp

This is the shell script $HOME/bin/findnest.sh:

#!/bin/bash

#findnest.sh

#

#find existing Nest and return FOUND Message or

#return a list of suitable writeable drive device names

#

if [ ! -e /mnt/nest/home/README.SCOOL ]

then

   HDRIVES=`ls /vol | grep "hd"`

   for HD in $HDRIVES

   do

      HSIZE=`df -m /vol/$HD | grep vol | awk '{print $3}'`

      if [ $HSIZE -gt 199 ]

      then

         echo "/vol/$HD Space $HSIZE MB"

      fi

   done

   if [ ${#HDRIVES} -lt 1 ]

   then

      echo "No suitable Drives"

   fi

else

   echo "FOUND"

fi

This shell script lists all the mounted hard drives it finds in the /vol folder, works out which are suitable, and prints the information out so that it can be viewed in the RunRev window, or if none are found it prints a message, or if there is already a nest, it returns "FOUND" to the RunRev calling script which uses this to do nothing. Finding USB Pen drives is not implemented as I have to compile the necessary modules for the Dyne:Bolic OS and activate them.

The BOOT button script:

on mouseUp

   put ($HOME & "/bin/findboot.sh") into FBOOT

   replace return with empty in FBOOT

   put the shell of FBOOT into GOTBOOT

   if GOTBOOT <> "FOUND"

   then

      put GOTBOOT into field "BLIST" of card "DYBOOT"

      go card "DYBOOT"

   end if

end mouseUp

The findboot.sh shell script:

#!/bin/bash

#findboot.sh

#

#find existing boot and return FOUND Message or

#return a list of suitable writeable drive device names

#

#Loop the vols

VNUM=0

VDONE=0

FBOOT=0

while [ $VDONE -lt 1 ]

do

   let VNUM=$VNUM+1

   if [ -e /vol/HD$VNUM ]

   then

      if [ -e /vol/HD$VNUM/dyne ]

      then

         #got one

         VDONE=1

         FBOOT=1

      fi

   else

      VDONE=1

   fi

done

#

if [ $FBOOT -lt 1 ]

then

   HDRIVES=`ls /vol | grep "hd"`

   for HD in $HDRIVES

   do

      HSIZE=`df -m /vol/$HD | grep vol | awk '{print $3}'`

      if [ $HSIZE -gt 699 ]

      then

         echo "/vol/$HD Space $HSIZE MB"

      fi

   done

   if [ ${#HDRIVES} -lt 1 ]

   then

      echo "No suitable Drives"

   fi

else

   echo "FOUND"

fi

The first part of this script looks through at the /vol mounted drives to see if there is an existing boot folder. If it doesn't find one, it performs the same actions as the findnest script.

This is the NETWORK button:

on mouseUp

   put ($HOME & "/bin/findnet.sh") into FNET

   replace return with empty in FNET

   put the shell of FNET into GOTNET

end mouseUp

This is the findnet.sh shell script:

#!/bin/bash

#findnet.sh

#

#find existing IP and return FOUND Message or

#find a spare Static IP and set it with ifconfig via the Dyne:Bolic utility

#

FOUND=0

FIP=`/sbin/ifconfig | grep "Mask" | awk '{print $2}'|\

awk -F":" '{print $2}' | cut -d"." -f1`

NFIP=`echo $FIP | grep "10"`

if [ ${#NFIP} -lt 1 ]

then

   NFIP=`echo $FIP | grep "192"`

   if [ ${#NFIP} -lt 1 ]

   then

      #Haven't got a network IP

      FOUND=0

   else

      FOUND=1

   fi

else

   FOUND=1

fi

if [ $FOUND -lt 1 ]

then

   /usr/bin/netconfig

fi 

I would have liked to find a tool for quickly and efficiently finding a spare static IP address and setting this up auto magically.

Using "ping -c 1 -w 1" would still have to cycle through 255 times 240 times 2 lots of IP numbers, which is a lot of seconds in time. If any one knows how to achieve this, please send stomfi an email.

The SCOOL button:

on mouseUp

   put ($HOME & "/bin/doscool.sh") into DUSCOOL

   replace return with empty in DUSCOOL

   put the shell of DUSCOOL into DUNSCOOL

end mouseUp

This is the doscool.sh shell script:

#!/bin/bash

#doscool.sh

#

#Kill SCLSPLASH

killall SCLSPLASH

#Launch SCOOL

$HOME/SCOOL/bin/SCOOL

exit

This shell script, uses killall to exit the splash screen and then launches the 'SCOOL application. You can see that I could have put extra similar buttons and scripts for launching the GIMP and Audacity, and even a text editor. You can modify the splash screen to launch you own apps including those with specific associated files that you want to open with your application.

This is the script for the DYBOOT window field.

on mouseDown

   put the selectedText of me into THISDRIVE

   put ($HOME & "/bin/doboot.sh" && THISDRIVE) into DUBOOT

   replace return with empty in DUBOOT

   put the shell of DUBOOT into DUNBOOT

   put DUNBOOT into field "BMSG"

end mouseDown

This is the doboot.sh shell script:

#!/bin/bash

#doboot.sh drive

#

#Create a boot system on the drive

echo "Wait for boot file creation to complete"

cp /mnt/dynebolic/dyne $1

echo "Boot created on $1"

The above script copies the files from the CD onto the selected drive.

This is the Restart your computer button:

on mouseUp

   put the shell of ("/sbin/shutdown -r now") into DUNBOOT

   quit

end mouseUp

Shutdown is the shell command that reboots or halts your system when you choose this option from your login screen. The -r option means reboot, and now is when it is to happen.

This is the DYNEST window field script:

on mouseDown

   put the selectedText of me into THISDRIVE

   put ($HOME & "/bin/donest.sh" && THISDRIVE) into DUNEST

   replace return with empty in DUNEST

   put the shell of DUNEST into DUNNEST

   put DUNNEST into field "NMSG"

end mouseDown

This is the donest.sh shell script.

#!/bin/bash

#donest.sh drive

#

#Create a nest on the drive

echo "Wait while nest is created"

/usr/bin/nidifica -s 115 -l $1

echo "Nest Created on $1"

This shell script use the Dyne:Bolic nest creation tool to create a 115MB nest on the selected drive.

This is the USING window SCOOL button:

on mouseUp

   put empty into field "USETXT"

   put ($HOME & "/scoolread.txt" ) into THISTEXT

   open file THISTEXT for read

   read from file THISTEXT until EOF

   close file THISTEXT

   put it into field "USETXT"

end mouseUp

The other buttons are the same except for the file name.

The CLOSE button on any card says:

on mouseUp

   go card "SPLASH"

end mouseUp

To get Dyne:Bolic to use this splash program instead of its own, you have to change where the /initrd/etc/rc.m script resets the top part of the WMState file.

Change the line which copies the WMState.head file to get the new file which is in /home/setup. This is a new folder created in /home and contains this file.

You can see I have changed the line which said "dynespalsh" to "/home/bin/SCLSPLASH". I copied this file from "/usr/share/dynebolic/templates/WMState.head" although you will need to boot Dyne:Bolic and copy this file from there to your development /vol/hddrive, unless you have implemented the squashfs file system as described in my article on installing it.

Finally it is a good idea to be able to restart the new splash screen from the menu. Here is the WM menu. The other one is in /home/.fluxbox/menu.

That's all for the Dyne:Bolic 'SCOOL CD. The last part of this article deals with starting the splash screen from KDE or Gnome under SUSE 9.2.

This is the Gnome setup, which you can find in the menu bar under System ? Control Centre.

I have added the /home/stomfi/bin/SCLSPLASH program here so that when Gnome starts it will appear on the screen.

This is the how to set it up in KDE:

In KDE, create a "link to application" by right clicking the desktop and choosing this item from "create new".

Give it a name in the first tab and point it to the application in the last tab. Create it and open Konqueror to the folder shown above. Drag the icon you just created from the desktop into this folder and choose "Move".

That's all there is to do. You can of course create a large splash screen that will fill the whole of your desktop, and you can use RunRev to stop the window buttons from working, switch off all the panels, disabling some of the desktop control sequences, effectively trapping the user onto your splash screen. You can delete the "killall" command for your various application startup buttons, which will ensure your splash screen remains as the background to any screen activities.

This is very useful for developing one off vertical applications, where you want to use the features of Gnome or KDE or any other window manager, but don't want to give your user access to the other menus and controls. I have found this approach is very effective when getting really young or older people to use a computer, where the complexity of the screen and menus is quite confusing.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell