Create menu from .suntools

Nick Holloway alfie at cs.warwick.ac.uk
Sun Dec 4 12:03:50 AEST 1988


I find it useful to have a menu that enables me to start up anything in my
.suntools (or .sunview if you have actually trained yourself to think
4.0ish) using a menu. If (say) your console dies (as if that would occur
:-), you can reach into your startup menu, and it can be restarted.

Another use that I have found, is for a quick login session. You can run
'suntools -n' and then pick a subset of the .suntools out of the menu.

The main problem is you need to be able to have some way of guessing the
startup item from the menu. The following (bourne) shell script helps to
do this, by using the tool stripe as an indication (if -Wl flag given) or
the program name otherwise. Thus given a .suntools of
    contool <position flags>
    shelltool -Wl "shelltool : alfie"

I get a menu that looks like
    "contool"    contool <position flags>
    "shelltool : alfie"     shelltool -Wl "shelltool : alfie"

To make this automatic, I have as the last entry in my .suntools
    'menu_update'

To use, you need to change the assignment of 'startup' and 'startupmenu' in
the top of the script
        Bye for now, Nick Holloway.
--
JANET : alfie at uk.ac.warwick.cs        | `O O' |16 Queens Rd|   /: :   :-- : :--
UUCP  : ..!mcvax!ukc!warwick!alfie    |//  \\|Hertford    |  / : :   :   : :
BITNET: alfie%uk.ac.warwick.cs at ukacrl --------|Herts       | /--: :   :-  : :-
ARPA  : alfie%cs.warwick.ac.uk at cunyvm.cuny.edu|England     |/   : :__ :   : :__

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#    menu_update
# This archive created: Tue Nov 22 14:29:45 1988
export PATH; PATH=/bin:$PATH
if test -f 'menu_update'
then
    echo shar: will not over-write existing file "'menu_update'"
else
sed 's/X//' << \SHAR_EOF > 'menu_update'
X#!/bin/sh
X#  Update the startups menu from the .suntools, so that anything that is
X#  in .suntools can be restarted using a menu. Much nicer than
X#  'eval `grep Console .suntools` &' from a window.
X
Xstartup=$HOME/.suntools
Xstartupmenu=$HOME/lib/rootmenu.startups
X
X# see if startup is newer than startupmenu
Xif [ "`ls -t $startup $startupmenu | head -1`" = "$startup" ]
Xthen
X    echo "`basename $0`: updating $startupmenu" 1>&2
X    (
X    while read line            # read line from startup
X    do
X        eval set - "$line"        # has side effect of stripping comments
X        if [ $# -eq 0 ]        # no command in line
X        then
X        continue
X        fi
X        label=$1            # initial attempt
X        while [ $# -ne 0 ]
X        do
X        if [ "x$1" = "x-Wl" ]    # found -Wl flag - use its arg
X        then
X            label=$2
X            shift
X        fi
X        shift
X        done
X        echo "\"$label\"    $line"    # output to startup menu
X    done
X    ) < $startup > $startupmenu
Xfi
SHAR_EOF
chmod +x 'menu_update'
fi # end of overwriting check
#    End of shell archive
exit 0



More information about the Comp.sys.sun mailing list