Novell Home

HowTo: Create and Use Stomfi's Cool School Show Part 3

Novell Cool Solutions: Feature
By Stomfi

Digg This - Slashdot This

Updated: 15 Mar 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

Cool School Show is a multimedia presentation, editing, and review system for students to include their own school work in any field of endeavour for viewing and rating by other students in friendly competition.

The first part of this how to showed you all the windows used in the system

The second part showed you the objects and scripts that make it all work.

This third part shows you the scripts so that the local user can edit and add new shows.

I have put this application, including some content and content howtos on my website so you can download a working version, which includes the development stack. It relies on the GIMP for image creation and editing, Audacity for sounds, and a text editor like "gedit" or "kate". I have a test group looking at it for problems, so it gets updated now and then. Look at the SCOOL page for the latest version, documentation, how to content and example content.

The important thing to remember about this application is that it is made from Open Source and freely distributable components and runs on Linux, so that it can be used by people all over the world, no matter what their economic status.

I have added an install script which you run after you have unzipped the application. The install script untars the main file structure into your home directory and runs the setup.sh script.

#!/bin/bash

#

#install.sh

#install current program in $HOME

PNAME=`ls *.tar.bz2|cut -d"." -f1`

mkdir "$HOME/$PNAME"

cd "$HOME/$PNAME"

tar xjvf $PNAME.tar.gz

if [ -e setup.sh ]

then

. ./setup.sh

fi

Using the dot (.) before ./setup.sh means run it inside thie calling shell with all its parameters. In this case it will know about PNAME.

#!/bin/bash

#

#setup.sh

#setup things for current program

#

#links to $HOME/$PNAME/bin for applications

#

#find gimp audacity and gedit

#

if [ ${#PNAME} -lt 1 ]

then

   exit

fi

GIMP=`whereis gimp`

NFLDS=`echo $GIMP | awk -F" " '{print NF}'`

for ((I = 1; I <= $NFLDS; I++))

do

   TFLD=`echo $GIMP | cut -d" " -f$I`

   GFLD=`echo $TFLD | grep "bin/"`

   if [ ${#GFLD} -gt 0 ]

   then

      GIMP="$GFLD"

      break

   else

      echo "The GIMP was not found on your system"

      echo "Install it and run the install script again"

   fi

done

AUD=`whereis audacity`

NFLDS=`echo $AUD | awk -F" " '{print NF}'`

for ((I = 1; I <= $NFLDS; I++))

do

   TFLD=`echo $AUD | cut -d" " -f$I`

   GFLD=`echo $TFLD | grep "bin/"`

   if [ ${#GFLD} -gt 0 ]

   then

      AUD="$GFLD"

      break

   else

      echo "Audacity was not found on your system"

      echo "Install it and run the install script again"

   fi

done

GEDIT=`whereis gedit`

NFLDS=`echo $GEDIT | awk -F" " '{print NF}'`

for ((I = 1; I <= $NFLDS; I++))

do

   TFLD=`echo $GEDIT | cut -d" " -f$I`

   GFLD=`echo $TFLD | grep "bin/"`

   if [ ${#GFLD} -gt 0 ]

   then

      TEDIT="$GFLD"

      break

   fi

done

if [ ${#TEDIT -lt 1 ]

then

   KEDIT=`whereis kate`

   NFLDS=`echo $KEDIT | awk -F" " '{print NF}'`

   for ((I = 1; I <= $NFLDS; I++))

   do

      TFLD=`echo $KEDIT | cut -d" " -f$I`

      GFLD=`echo $TFLD | grep "bin/"`

      if [ ${#GFLD} -gt 0 ]

      then

         TEDIT="$GFLD"

         break

      else

         TEDIT="xterm -e vi"

         echo "Neither gedit or kate were found on your system"

         echo "the editor has been set to vi in an xterminal"

      fi

   done

fi

#setup a sound player. mplayer or play

MPLAY=`whereis mplayer`

NFLDS=`echo $MPLAY | awk -F" " '{print NF}'`

for ((I = 1; I <= $NFLDS; I++))

do

   TFLD=`echo $MPLAY | cut -d" " -f$I`

   GFLD=`echo $TFLD | grep "bin/"`

   if [ ${#GFLD} -gt 0 ]

   then

      SPLAY="$GFLD"

      break

   fi

done

if [ ${#SPLAY -lt 1 ]

then

   PLAY=`whereis play`

   NFLDS=`echo $PLAY | awk -F" " '{print NF}'`

   for ((I = 1; I <= $NFLDS; I++))

   do

      TFLD=`echo $PLAY | cut -d" " -f$I`

      GFLD=`echo $TFLD | grep "bin/"`

      if [ ${#GFLD} -gt 0 ]

      then

         SPLAY="$GFLD"

         break

      else

         echo "Neither mplayer or play were found on your system"

         echo "Install either Mplayer or Sox and run install again"

      fi

   done

fi

if [ ${#GIMP} -gt 1 ]

then

   ln -s $GIMP $HOME/$PNAME/bin/gimp

fi

if [ ${#AUD} -gt 1 ]

then

   ln -s $AUD $HOME/$PNAME/bin/audacity

fi

ln -s $TEDIT $HOME/$PNAME/bin/tedit

if [ ${#SPLAY} -gt 1 ]

then

   ln -s $SPLAY $HOME/$PNAME/bin/sndplayer

fi

Here is another picture of the Add Show window:

These are all the runrev scripts for this page.

on openCard

   global NEWTIME

   if NEWTIME <> "NO"

   then

      put ($HOME & "/SCOOL/bin/showlist.sh") into SHOWLIST

      put the shell of SHOWLIST into field "Showlist"

      put empty into field "Showname"

      put empty into field "Smessage"

      put empty into field "Addheader"

      put empty into field "PICLIST"

      put empty into field "TEXTLIST"

      put empty into field "SNDLIST"

      global NSHEADER

      put "NO" into NSHEADER

   end if

   put "NO" into NEWTIME

end openCard

Enter show name button

on mouseUp

   global NSNAME

   ask "Enter a single word for the name of the Show"

   put it into NSNAME

   if NSNAME <> empty

   then

      put NSNAME into field "Showname"

      #If existing show unzip it into tmp directory and return the header

      put ($HOME & "/SCOOL/bin/tmpunzip.sh" && quote & NSNAME & quote) into TMPUNZIP

      replace return with empty in TMPUNZIP

      put the shell of TMPUNZIP into HEADUNZIP

      #Put the header into the header field

      put HEADUNZIP into field "Addheader"

      #set the NSHEADER global

      if field "Addheader" <> empty

      then

         #This is an existing show

         global NSHEADER

         put "YES" into NSHEADER

         #Fill the existing show elements fields

         put ($HOME & "/SCOOL/bin/getelist.sh" && quote & NSNAME & quote) into GETELIST

         replace return with empty in GETELIST

         put (GETELIST && quote & "PIC" & quote) into DUPICLIST

         replace return with empty in DUPICLIST

         put the shell of DUPICLIST into field "PICLIST"

         put (GETELIST && quote & "TEXT" & quote) into DUTEXTLIST

         replace return with empty in DUTEXTLIST

         put the shell of DUTEXTLIST into field "TEXTLIST"

         put (GETELIST && quote & "SND" & quote) into DUSNDLIST

         replace return with empty in DUSNDLIST

         put the shell of DUSNDLIST into field "SNDLIST"

         #set the NEWSDIR global

         global NEWSDIR

         put ($HOME & "/SCOOL/tmp/" & NSNAME) into NEWSDIR

         replace return with empty in NEWSDIR

      else

         #Make a new temp directory for new show

         global NEWSDIR

         put ($HOME & "/SCOOL/tmp/" & NSNAME) into NEWSDIR

         replace return with empty in NEWSDIR

         put ("mkdir" && NEWSDIR) into MKSDIR

         put the shell of MKSDIR into DUNDIR

      end if

   end if

end mouseUp

Add or change header button

on mouseUp

   put "No" into DOIT

   global NSHEADER

   if NSHEADER = "YES"

   then

      answer "Do you really want to change this Header" with "Yes" or "No"

      put it into HANS

      if HANS = "Yes"

      then

         put empty into field "Addheader"

         put "Yes" into DOIT

      end if

   else

      put "Yes" into DOIT

   end if

   if DOIT = "Yes"

   then

      ask "Enter a Short Description for Show"

      put it into SHOWDESC

      ask "Enter Copyright name"

      put it into COPNAME

      ask "Enter Copyright Year"

      put it into COPYEAR

      put SHOWDESC & return into field "Addheader"

      put ("by" && COPNAME && "(C)" && COPYEAR) after field "Addheader"

      put "YES" into NSHEADER

      global NSNAME

      put ($HOME & "/SCOOL/tmp/" & NSNAME & "/header.txt") into HEADFILE

      replace return with empty in HEADFILE

      open file HEADFILE for write

      write field "Addheader" to file HEADFILE

      close file HEADFILE

   end if

end mouseUp

Add New Pictures button

on mouseUp

   #Count lines in PICLIST for next directory number

   global PICLINES

   put the number of lines of field "PICLIST" into PICLINES

   go card "Addpic"

end mouseUp

Edit existing Picture button

on mouseUp

   put the number of lines of the field "PICLIST" into NUMPICS

   if NUMPICS > 0

   then

      put ("Enter Picture Directory Number between 1 and" && NUMPICS) into PMSG

      ask PMSG

      put it into PASK

      if PASK > 0 and PASK <= NUMPICS

      then

         put line PASK of field "PICLIST" into PFILE

         put ($HOME & "/SCOOL/bin/gimp") into DOGIMP

         #DOGIMP is a link to where ever the GIMP resides on your system

         #it is usually made when you install SCOOL with the setup shell

         replace return with empty in DOGIMP

         launch PFILE with DOGIMP

      end if

   end if

end mouseUp

Add New Texts button

on mouseUp

   #Count lines in TEXTLIST for next directory number

   global TXTLINES

   put the number of lines of field "TEXTLIST" into TXTLINES

   go card "Addtext"

end mouseUp

Edit Existing Text button

on mouseUp

   put the number of lines of the field "TEXTLIST" into NUMTEXTS

   if NUMTEXTS > 0

   then

      put ("Enter Text Directory Number between 1 and" && NUMTEXTS) into TMSG

      ask TMSG

      put it into TASK

      if TASK > 0 and TASK <= NUMTEXTS

      then

         put line TASK of field "TEXTLIST" into TFILE

         put ($HOME & "/SCOOL/bin/tedit") into DOTEDIT

         replace return with empty in DOTEDIT

         #DOTEDIT is a link to where ever the EDITOR resides on your system

         #it is usually made when you install SCOOL with the setup shell

         launch TFILE with DOTEDIT

      end if

   end if

end mouseUp

Add New Sounds button

on mouseUp

   #Count lines in SNDLIST for next directory number

   global SNDLINES

   put the number of lines of field "SNDLIST" into SNDLINES

   go card "Addsnd"

end mouseUp

Edit Existing Sound button

on mouseUp

   put the number of lines of the field "SNDLIST" into NUMSNDS

   if NUMSNDS > 0

   then

      put ("Enter Sound Directory Number between 1 and" && NUMSNDS) into SMSG

      ask SMSG

      put it into SASK

      if SASK > 0 and SASK <= NUMSNDS

      then

         put line SASK of field "SNDLIST" into SFILE

         put ($HOME & "/SCOOL/bin/audacity") into DOSND

         replace return with empty in DOSND

         #DOSND is a link to where ever Audacity resides on your system

         #it is usually made when you install SCOOL with the setup shell

         launch SFILE with DOSND

      end if

   end if

end mouseUp

TEST button

on mouseUp

   global NSNAME

   global NSHEADER

   if NSNAME <> empty and NSHEADER <> "NO"

   then

      go card "Showtest"

   else

      put "Name or Header not done" into field "Smessage"

   end if

end mouseUp

Discard Changes button

on mouseUp

   #Discard all the changes by removing the temporary directory

   answer "Are you sure you want to discard all your changes" with "No" and "Yes"

   put it into DASK

   if DASK = "Yes"

   then

      global NSNAME

      put ($HOME & "/SCOOL/tmp/" & NSNAME) into DELDIR

      replace return with empty in DELDIR

      put the shell of ("rm -fr" && DELDIR) into DUNDEL

      go card "SHENTRY"

   end if

end mouseUp

And these are all the associated shell scripts.

#!/bin/bash

#showlist.sh

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#Return names of files in library without extension

SFILES=`ls $HOME/SCOOL/library/*`

for F in $SFILES

do

   SFNAME=`basename $F | cut -d"." -f1`

   echo "$SFNAME"

done


#!/bin/bash

#tmpunzip.sh showname

#

#Unzip library file to tempory work directory

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#If name exists return header text

#Set the root directory

SROOT="$HOME/SCOOL"

#find out whether showname exists in library

ESHOW="$1.zip"

#Send the standard error to the bottomless pit /dev/null

ISSHOW=`ls $SROOT/library/$ESHOW 2> /dev/null`

if [ ${#ISSHOW} -gt 0 ]

then

   #There is a show with this name

   #so file needs to extracted from the library

   #First make sure that there isn't an old file in there

   rm -fr $SROOT/tmp/$1 2> /dev/null

   unzip $SROOT/library/$ESHOW -d $SROOT/tmp 2>&1 > /dev/null

   #Get the header from the show

   HEADER="$SROOT/tmp/$1/header.txt"

   cat $HEADER

fi


#!/bin/bash

#getelist.sh showname type

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#Set the root directory

STMP="$HOME/SCOOL/tmp/$1"

#Return a subdirectory file list for type

case $2 in

   "PIC") ls -1 $STMP/*/pic.* 2> /dev/null ;;

   "TEXT") ls -1 $STMP/*/text.txt 2> /dev/null ;;

   "SND") ls -1 $STMP/*/snd.* 2> /dev/null ;;

esac

These are the scripts for all the sub cards under the Add Show card.

Add Picture Card

on openCard

   global NSNAME

   put NSNAME into field "Showname"

   set the filename of image "Newpic" to empty

end openCard

Add Picture button

on mouseUp

   answer file "Please Select a picture file"

   put it into PICFILE

   if PICFILE <> empty

   then

      #Find out whether image is within bounds of height = 500 width = 500

      #and scale if necessary

      put ($HOME & "/SCOOL/bin/picscale.sh" && quote & PICFILE & quote) into PICSCALE

      replace return with empty in PICSCALE

      put the shell of PICSCALE into NPICFILE

      #Shell returns have a newline at the end

      replace return with empty in NPICFILE

      set the filename of image "Newpic" to NPICFILE

   end if

end mouseUp

Discard button

on mouseUp

   #delete the temporary picture file

   put the filename of image "Newpic" into PICFILE

   put ("rm -f" && PICFILE) into DELTFILE

   replace return with empty in DELTFILE

   put the shell of DELTFILE into DUNDELF

   go card "Addshow"

end mouseUp

Done button

on mouseUp

   if the filename of image "Newpic" <> empty

   then

      #Get the next empty pic directory

      global PICLINES

      add 1 to PICLINES

      #Make the directory

      #Recreate NEWSDIR and NSNAME just in case

      global NEWSDIR

      put field "Showname" into NSNAME

      put ($HOME & "/SCOOL/tmp/" & NSNAME) into NEWSDIR

      replace return with empty in NEWSDIR

      put (NEWSDIR & "/" & PICLINES) into PICDIR

      replace return with empty in PICDIR

      put the shell of ("mkdir" && PICDIR) into DUNPICDIR

      #Now we have a PICDIR

      put the filename of image "Newpic" into NEWPIC

      #Use the shell to perform the copy so we can change its name

      put ($HOME & "/SCOOL/bin/copypic.sh" && NEWPIC && PICDIR) into COPPIC

      replace return with empty in COPPIC

      put the shell of COPPIC into DUNCOP

      #Now we need to put the new line into PICLIST of the Addshow card

      global NSNAME

      put ($HOME & "/SCOOL/bin/getelist.sh" && NSNAME && quote & "PIC" & quote) into LISTSH

      replace return with empty in LISTSH

      put the shell of LISTSH into field "PICLIST" of card "Addshow"

      #delete the temporary picture file

      put ("rm -f" && PICFILE) into DELTFILE
      
      replace return with empty in DELTFILE

      put the shell of DELTFILE into DUNDELF

   end if

   go card "Addshow"

end mouseUp

Add Text card

on openCard

   global NSNAME

   put NSNAME into field "Showname"

   put empty into field "Addtext"

end openCard

Discard button

on mouseUp

   go card "Addshow"

end mouseUp

Done button

on mouseUp

   if field "Addtext" <> empty

   then

      #Get the next empty text directory

      global TXTLINES

      add 1 to TXTLINES

      #Make the directory

      global NEWSDIR

      put (NEWSDIR & "/" & TXTLINES) into TXTDIR

      replace return with empty in TXTDIR

      put the shell of ("mkdir" && TXTDIR) into DUNTXTDIR

      #Now we have a TXTDIR

      #Use the open file command to write the new text

      put (TXTDIR & "/text.txt") into COPTXT

      replace return with empty in COPTXT

      open file COPTXT for write

      write field "Addtext" to file COPTXT

      close file COPTXT

      #Now we need to put the new line into TEXTLIST of the Addshow card

      global NSNAME

      put ($HOME & "/SCOOL/bin/getelist.sh" && NSNAME && quote & "TEXT" & quote) into LISTSH

      replace return with empty in LISTSH

      put the shell of LISTSH into field "TEXTLIST" of card "Addshow"

   end if

   go card "Addshow"

end mouseUp

Add Sound card

on openCard

   global NSNAME

   put NSNAME into field "Showname"

   put empty into field "Newsnd"

end openCard

Add Sound button.

on mouseUp

   answer file "Enter name of new Sound file"

   put it into SNDFILE

   if SNDFILE <> empty

   then

      #Display the chosen file name

      put SNDFILE into field "Newsnd"

   end if

end mouseUp

Test New Music button

on mouseUp

   if field "Newsnd" <> empty

   then

      #Play the music at 50% volume

      put the shell of ("aumix -v50") into SETMUS

      put field "Newsnd" into THISMUS

      put ($HOME & "/SCOOL/bin/playsnd.sh" && THISMUS) into PLAYSND

      replace return with empty in PLAYSND

      put the shell of PLAYSND into DUSND

   end if

end mouseUp

+ button

on mouseUp

   put ($HOME & "/SCOOL/bin/increase.sh") into LOUDER

   replace return with empty in LOUDER

   put the shell of LOUDER into DUNPLUS

end mouseUp

- button

on mouseUp

   put ($HOME & "/SCOOL/bin/increase.sh") into SOFTER

   replace return with empty in SOFTER

   put the shell of SOFTER into DUNMINUS

end mouseUp

Discard button

on mouseUp

   go card "Addshow"

end mouseUp

Done button

on mouseUp

if field "Newsnd" <> empty

then

   #Get the next empty snd directory

   global SNDLINES

   add 1 to SNDLINES

   #Make the directory

   global NSNAME

   put ($HOME & "/SCOOL/tmp/" & NSNAME) into NEWSDIR

   put (NEWSDIR & "/" & SNDLINES) into SNDDIR

   replace return with empty in SNDDIR

   put the shell of ("mkdir -f" && SNDDIR) into DUNSNDDIR

   #Now we have a SNDDIR

   put field "Newsnd" into NEWSND

   #Use the shell to perform the copy so we can change its name

   put ($HOME & "/SCOOL/bin/copysnd.sh" && quote & NEWSND & quote && quote & SNDDIR & quote) into COPSND

   replace return with empty in COPSND

   put the shell of COPSND into DUNSND

   #Now we need to put the new line into SNDLIST of the Addshow card

   global NSNAME

   put ($HOME & "/SCOOL/bin/getelist.sh" && quote & NSNAME & quote && quote & "SND" & quote) into LISTSH

   replace return with empty in LISTSH

   put the shell of LISTSH into field "SNDLIST" of card "Addshow"

end if

   go card "Addshow"

end mouseUp

TEST card

on openCard

   #Display the new or editted show named in NSNAME

   # The references to the first display page are returned.

   global NSNAME

   put ($HOME & "/SCOOL/bin/testshow.sh 1" && quote & NSNAME & quote) into DOSHOW

   replace return with empty in DOSHOW

   put the shell of DOSHOW into GETSHOW

   put line 1 of GETSHOW into SHEAD

   put line 2 of GETSHOW into STEXT

   put line 3 of GETSHOW into SPIC

   put line 4 of GETSHOW into SMUSIC

   #create global references for the page buttons

   global TPNUM

   put line 5 of GETSHOW into TPNUM

   #Create a global reference for the current page number

   global TPAGE

   put 1 into TPAGE

   #Load up the card

   open file SHEAD for read

   read from file SHEAD until EOF

   close file SHEAD

   put it into field "SHOWHEAD"

   open file STEXT for read

   read from file STEXT until EOF

   close file STEXT

   if STEXT <> empty

   then

      put it into field "SHOWTEXT"

   end if

   if SPIC <> empty

   then

      set the filename of image "SHOWPIC" to SPIC

   end if

   global THISMUS

   put empty into THISMUS

   if SMUSIC <> empty

   then

      put SMUSIC into THISMUS

   end if

   #end of load

end openCard

Test Music button.

on mouseUp

   global THISMUS

   if THISMUS <> empty

   then

      #Play the music at 50% volume

      put the shell of ("aumix -v50") into SETMUS

      put ($HOME & "/SCOOL/bin/playsnd.sh" && THISMUS) into PLAYSND

      replace return with empty in PLAYSND

      put the shell of PLAYSND into DUSND

   end if

end mouseUp

BACK button

on mouseUp

   #Get the show references

   #Current page number

   global TPAGE

   #This contains the number of pages

   global TPNUM

   if TPAGE > 1

   then

      put empty into field "Tmessage"

      subtract 1 from TPAGE

      #Repeat the load commands

      global NSNAME

      put ($HOME & "/SCOOL/bin/testshow.sh" && TPAGE && quote & NSNAME & quote) into DOSHOW

      replace return with empty in DOSHOW

      put the shell of DOSHOW into GETSHOW

      put line 1 of GETSHOW into SHEAD

      put line 2 of GETSHOW into STEXT

      put line 3 of GETSHOW into SPIC

      put line 4 of GETSHOW into SMUSIC

      #Load up the card

      open file SHEAD for read

      read from file SHEAD until EOF

      close file SHEAD

      put it into field "SHOWHEAD"

      open file STEXT for read

      read from file STEXT until EOF

      close file STEXT

      if STEXT <> empty

      then

         put it into field "SHOWTEXT"

      end if

      if SPIC <> empty

      then

         set the filename of image "SHOWPIC" to SPIC

      end if

      #Stop and change the music

      global THISMUS

      if THISMUS <> empty

      then

         #could be some playing from previous page

         put ($HOME & "/SCOOL/bin/stopsnd.sh") into STOPMUS

         replace return with empty in STOPMUS

         put the shell of STOPMUS into DUNSTOP

      end if

      put empty into THISMUS

      if SMUSIC <> empty

      then

         put SMUSIC into THISMUS

      end if

      #end of load

   else

      put "No More Cards" into field "Tmessage"

   end if

end mouseUp

QUIT button

on mouseUp

   go to card "Addshow"

end mouseUp

NEXT button

on mouseUp

   #Get the show references

   #Current page number

   global TPAGE

   #This contains the number of pages

   global TPNUM

   if TPAGE < TPNUM

   then

      put empty into field "Tmessage"

      add 1 to TPAGE

      #Repeat the load commands

      global NSNAME

      put ($HOME & "/SCOOL/bin/testshow.sh" && TPAGE && quote & NSNAME & quote) into DOSHOW

      replace return with empty in DOSHOW

      put the shell of DOSHOW into GETSHOW

      put line 1 of GETSHOW into SHEAD

      put line 2 of GETSHOW into STEXT

      put line 3 of GETSHOW into SPIC

      put line 4 of GETSHOW into SMUSIC

      #Load up the card

      open file SHEAD for read

      read from file SHEAD until EOF

      close file SHEAD

      put it into field "SHOWHEAD"

      open file STEXT for read

      read from file STEXT until EOF

      close file STEXT

      if STEXT <> empty

      then

         put it into field "SHOWTEXT"

      end if

      if SPIC <> empty

      then

         set the filename of image "SHOWPIC" to SPIC

      end if

      #Stop and change the music

      global THISMUS

      if THISMUS <> empty

      then

         #could be some playing from previous page

         put ($HOME & "/SCOOL/bin/stopsnd.sh") into STOPMUS

         replace return with empty in STOPMUS

         put the shell of STOPMUS into DUNSTOP

      end if

      put empty into THISMUS

      if SMUSIC <> empty

      then

         put SMUSIC into THISMUS

      end if

      #end of load

   else

      put "No MorePages" into field "Tmessage"

   end if

end mouseUp

Save Show button

on mouseUp

   global NSNAME

   put ($HOME & "/SCOOL/bin/saveshow.sh" && quote & NSNAME & quote) into SAVESHOW

   replace return with empty in SAVESHOW

   put the shell of SAVESHOW into DUNSAVE

   go card "SHENTRY"

end mouseUp

And here are the associated shell scripts

#!/bin/bash

#picscale.sh picfile

#

#Copy picfile to show temp directory

#If required scale the picfile

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#Set the bounds with the ImageMagick tools as long as they are available

#They should be in /usr/bin

#find out the file basename

BNAME=`basename "$1"`

#Set the tempfile name

TFILE="$HOME/SCOOL/tmp/$BNAME"

if [ -e /usr/bin/identify ]

then

   BOUNDS=500

   #Set the original file name

   OFILE="$1"

   #Use identify from the ImageMagick suite to find out dimensions

   ###Added head -1 in case the file is an animation###

   PDIMS=`identify $OFILE | awk '{print $3}' | head -1`

   PWIDTH=`echo $PDIMS | cut -d"x" -f1`

   PHEIGHT=`echo $PDIMS | cut -d"x" -f2`

   #Check either one is not out of bounds

   if [ $PWIDTH -gt $BOUNDS -o $PHEIGHT -gt $BOUNDS ]

   then

      #Scale the image using convert from the ImageMagick suite

      #and save it in the temp file

      convert -scale 500x500 $OFILE $TFILE

   else 

      #Copy original to temp file

      cp "$1" "$TFILE"

   fi

else

   #can't do the scaling

   cp "$1" "$TFILE"

fi

#return the file name

echo $TFILE 


#!/bin/bash

#copypic.sh picfile showdir

#

#Copy the picfile to the show directory

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#find out the file extension

EXT=`echo "$1" | cut -d"." -f2`

cp "$1" "$2/pic.$EXT"


#!/bin/bash

#playsnd.sh soundfile

THISSND=$1

#Use Linux to play the sound as RunRev uses QuickTime

#which is not on my computer

#play is part of the sox suite and is usually on most Linux distros

#Or if you want to loop the sound you cam install mplayer

#Play the sound in the background so that this process will

#return to the calling program and lower its priority so it

#doesn't take too much resources

#send any shell output into the bottomless pit with 2>&1

#

#$HOME/SCOOL/bin/sndplayer should contain a link to the sound player

#The link is set in the application install/setup scripts

SNDPLAYER="$HOME/SCOOL/bin/sndplayer"

if [ -e $SNDPLAYER ]

then

   #play it

   #nice $SNDPLAYER $THISSND 2>&1 >/dev/null &

   #You could see if you've got mplayer as the link

   #I'll let you work this out as you can loop the sound

   #nice $SNDPLAYER -loop 0 $THISSND 2>&1 >/dev/null &

   nice $SNDPLAYER $THISSND 2>&1 >/dev/null &

fi


#!/bin/bash

#copysnd.sh soundfile showdir

#

#Copy the soundfile to the show directory

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#find out the file extension

EXTN=`echo $1 | cut -d"." -f2`

cp "$1" "$2/snd.$EXTN"


#!/bin/bash

#testshow.sh pagenumber showname

#

#Test the new show before it is saved

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#Set the TSHOW directory

TSHOW="$HOME/SCOOL/tmp/$2"

#Get the page stuff from the show

HEADER="$TSHOW/header.txt"

NUMPAGES=`ls -1 $TSHOW/*| wc -l`

let NUMPAGES=($NUMPAGES - 1)

PAGEDIR="$TSHOW/$1"

#Check to see if each file exists or echo a ""

ISTEXTFILE=`ls $PAGEDIR/text.txt 2> /dev/null`

if [ ${#ISTEXTFILE} -gt 0 ]

then

   TEXTFILE="$PAGEDIR/text.txt"

else

   TEXTFILE=""

fi

ISPICFILE=`ls $PAGEDIR/pic.* 2> /dev/null`

if [ ${#ISPICFILE} -gt 0 ]

then

   PICFILE="$ISPICFILE"

else

   PICFILE=""

fi

ISSNDFILE=`ls $PAGEDIR/snd.* 2> /dev/null`

if [ ${#ISSNDFILE} -gt 0 ]

then

   SNDFILE="$ISSNDFILE"

else

   SNDFILE=""

fi

echo "$HEADER"

echo "$TEXTFILE"

echo "$PICFILE"

echo "$SNDFILE"

echo "$NUMPAGES"


#!/bin/bash

#saveshow.sh showname

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#Go to temp directory

cd $HOME/SCOOL/tmp

SHOWNAME="$1"

ZIPFILE="$SHOWNAME.zip"

#If the file exists in the library, move it to a temporary file.

IFEXIST=`ls $HOME/SCOOL/library/$ZIPFILE 2> /dev/null`

if [ ${#IFEXIST} -gt 0 ]

then

   MOVFILE="$SHOWNAME.old"

   mv "$HOME/SCOOL/library/$SHOWNAME.zip" "$HOME/SCOOL/tmp/$MOVFILE"

fi

#zip the file into the library

zip -r $HOME/SCOOL/library/$SHOWNAME $SHOWNAME 2> /dev/null

#Check that the file is there. If not replace it with the moved one

#

IFNEW=`ls "$HOME/SCOOL/library/$ZIPFILE" 2> /dev/null`

if [ ${#IFNEW} -lt 1 ]

then

   OLDFILE="$SHOWNAME.old"

   mv "$HOME/SCOOL/tmp/$OLDFILE" "$HOME/SCOOL/library/$ZIPFILE"

else

   #remove the old file

   IFOLD=`ls $HOME/SCOOL/tmp/$OLDFILE 2> /dev/null`

   if [ ${#IFOLD} -gt 0 ]

   then

      rm -f "$HOME/SCOOL/tmp/$OLDFILE"

   fi

fi

#Clean up the temp directory

IFTMP=`ls $HOME/SCOOL/tmp/$SHOWNAME 2> /dev/null`

if [ ${#IFTMP} -gt 0 ]

then

   rm -rf "$HOME/SCOOL/tmp/$SHOWNAME"

fi

#Clean up the show directory

IFTMP=`ls $HOME/SCOOL/show/$SHOWNAME 2> /dev/null`

if [ ${#IFTMP} -gt 0 ]

then

   rm -rf "$HOME/SCOOL/show/$SHOWNAME"

fi

One final thing to do is some changes to the other scripts. One urgently needed to the SHENTRY card script, just in case the temp directory gets deleted. Nothing works if that happens.

on openCard

   put ("mkdir -f" && $HOME & "/SCOOL/tmp") into MKTMP

   replace return with empty in MKTMP

   put the shell of MKTMP into DUNTMP

   put ($HOME & "/SCOOL/bin/showlist.sh") into SHOWLIST

   put the shell of SHOWLIST into field "Showlist"

end openCard

Others are to do with the links. If you are not running the install script and building this from scratch (Excellent choice), you will have to put in the links by hand or modify the setup.sh script so that PNAME=SCOOL and run it.

Lastly, if I forgot to replace any pause statements with the stopsnd.sh shell script construct, or haven't replaced playLoudness with the increase or decrease sound scripts. Please forgive me and DIY. These are they.

#!/bin/bash

#increase.sh

#

#increase the sound volume with aumix

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#find out the current volume

VOL=`aumix -vq | cut -d"," -f2`

if [ $VOL -lt 100 ]

then

   let NEWVOL=($VOL + 10)

   if [ $NEWVOL -gt 100 ]

   then

      NEWVOL=100

   fi

fi

aumix -v$NEWVOL


#!/bin/bash

#decrease.sh

#

#Decrease the sound volume with aumix

#

# Copyright Stomfi (C) 2005

# This program is free software;

# you can redistribute it and/or modify it under the terms of the

# GNU General Public License as published by the Free Software Foundation;

# either version 2 of the License, or any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#

#find out the current volume

VOL=`aumix -vq | cut -d"," -f2 `

if [ $VOL -gt 9 ]

then

   let NEWVOL=($VOL - 10)

else

   NEWVOL=0

fi

aumix -v$NEWVOL

That's it folks. The Cool School Show is completed. Now all that's left to do is to get it to run on a Microsoft dominated machine, and spread it into every school or creative institution in the world. We shall have a look at how to make the show run from a bootable CD and a persistent HOME folder on an MS formatted hard drive in the final part of this series. There will be other Linux programs on the CD so that its users will be exposed to the wonderful world of Tux the penguin.

Don't forget to have a look at Stomfi's web site at www.stomfi.bigpondhosting.com for working examples of this and other Stomfi applications that have been described in the Stomfi articles.


Copyright Notice

Copyright Stomfi © 2005

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.


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

© 2014 Novell