First pass at script to build start menu icons

Harold L Hunt II huntharo@msu.edu
Fri Aug 8 12:45:00 GMT 2003


Brian,

That script looks great to me.

I would like some input on a few things before I go ahead with this 
(unless no one responds, in which case I will just go ahead):

The list of programs to create icons for is embedded in the script 
itself.  The script will still work, since I just copy the whole thing 
to /etc/postinstall/XWin-bin-icons.sh.  However, I was thinking about 
how we should probably install this script in /usr/X11R6/bin and the 
list of icons in some other location.  That way a user could manually 
run or rerun the script to replace icons that they had removed 
accidentally.  Furthermore, having the list of icons in a plain text 
file would allow the creation of a preremove script that (is this 
possible?) did a diff between the old icon list and the new icon list to 
find out which icons were being specifically removed between versions.

Alternatively, we could make the preremove script remove the entire list 
of icons that were created the first time, then have the upgraded 
postinstall script just put them all back.  In any case it would be 
smart to have that list of icons in a shared location so that the 
postinstall and preremove scripts could both reference it.

Thanks for contributing Brian, I really appreciate it.

Harold

Brian E. Gallew wrote:
> OK, it took me a little longer to get the script to this point than I 
> would have liked, BUT I'm pretty happy with the results.  Comments are 
> welcome, flames > /dev/null.
> 
> 
> ------------------------------------------------------------------------
> 
> #! /bin/sh
> # Author: Brian Gallew <geek+@cmu.edu>
> 
> TOPFOLDER="$(cygpath -A -P)/Cygwin-XFree86"
> 
> #Ensure that a given program is somewhere in the current $PATH
> function checkpath () {
>     c=$(which $1 2> /dev/null)
>     test ! -z "$c"
> }
> 
> # Create a shortcut for an application that draws its own windows
> # Takes four or five arguments: appname, description folder, the
> # offset of the icon , and any arguments
> 
> function xapp () {
>     app="$1"
>     shift
>     description="$1"
>     shift
>     folder="${TOPFOLDER}/$1"
>     shift
>     icon="--icon=/cygwin.ico"
>     test -z "$2" || icon="--iconoffset=$2"
>     shift
>     test -d "${folder}" || mkdir -p "${folder}"
>     mkshortcut "${icon}" --arguments=${app}\ -display\ :0\ "$@" \
> 	--name="${folder}/${description}" \
> 	--workingdir="${HOME}" /usr/X11R6/bin/run.exe
> }
> 
> # Create a shortcut for a text-output-only application
> function tapp () {
>     app="$1"
>     shift
>     description="$1"
>     shift
>     folder="${TOPFOLDER}/$1"
>     shift
>     test -d "${folder}" || mkdir -p "${folder}"
>     mkshortcut --arguments=xterm\ -display\ :0\ -e\ sh\ -c\ \"${app}\ -display\ :0\ "$@"\ "| less"\" \
> 	--name="${folder}/${description}" --icon=/cygwin.ico \
> 	--workingdir="${HOME}" /usr/X11R6/bin/run.exe
>     test $? -eq 0 && return
>     echo $app:$description:$folder::
> }
> 
> #format of an entry here:
> #executable name:Description:sub-folder:which function to call:icon offset:arguments
> #If the sub-folder is empty, then the icon will be placed in $TOPFOLDER
> #the "function to call" should be either xapp or tapp
> #If the program provides its own icon in the executable, this is the offset for it (0 based)
> #The arguments (if any) will be appended to the command.
> X11proggies=(
> bitmap:"Bitmap Editor"::xapp::
> dpsexec:"Display PostScript command interface":Tools:tapp::
> dpsinfo:"The Display PostScript extension":Information:tapp::
> editres:"Xaw resource editor":Tools:xapp::
> fc-list:"List available FreeType fonts":Information:tapp::
> glxgears:"Gear Demo":Toys:xapp::
> glxinfo:"GLX information":Information:tapp::
> ico:"Bouncing Icosohedron":Toys:xapp::
> oclock:"Shaped Clock"::xapp::
> showrgb:"List rgb database":Information:tapp::
> texteroids:"DPS demo asteroids game":Games:xapp::
> viewres:"Xaw resource viewer":Tools:xapp::
> vncviewer:"VNC viewer client"::xapp::
> wmagnify:"magnifying glass":Tools:xapp::
> xbiff:"mail checker"::xapp::
> xcalc:"Calculator"::xapp::
> xclock:"Clock"::xapp::
> xconsole:"Console":Tools:xapp::
> xcutsel:"Clipboard manipulator":Tools:xapp::
> xditview:"Ditroff output viewer"::xapp::
> xdpyinfo:"Display information":Information:tapp::
> xdvi:"DVI viewer"::xapp::
> xedit:"Simple file editor":Tools:xapp::
> xev:"X11 event debugger":Tools:xapp::
> xeyes:"Watches the Mouse":Toys:xapp::
> xfontsel:"Pick a font":Tools:tapp::
> xfsinfo:"The font server":Information:tapp::
> xgc:"X11 demo":Toys:xapp::
> xkill:"Kill an X11 window":Tools:xapp::
> xlogo:"Display the X11 logo":Toys:xapp::
> xlsatoms:"List available atoms":Information:tapp::
> xlsclients:"List all connected clients":Information:tapp::
> xlsfonts:"List all available fonts":Information:tapp::
> xmag:"Magnifying glass":Tools:xapp::
> xman:"Manual page reader"::xapp::
> xmh:"GUI for the MH mail system"::xapp::
> xprop:"Display the propertis of a window":Information:tapp::
> xrefresh:"Refresh all X11 clients":Tools:xapp::
> xterm:"X Terminal"::xapp:0:
> xtrapinfo:"The TRAP extension":Information:tapp::
> xvinfo:"The X-Video Extension":Information:tapp::
> xwd:"Dump X11 window image to file":Tools:tapp::
> xwininfo:"A single window":Information:tapp::
> gvim:"GUI for VIM"::xapp:0:
> emacs:"Editor"::xapp:0:
> xemacs:"Editor"::xapp:0:
> idle:"Python IDE"::xapp::
> rxvt:"RXVT"::xapp:0:
> )
> 
> for index in $(seq 0 ${#X11proggies[*]})
> do
>     a=${X11proggies[$index]}
>     test -z "$a" && continue
>     # This next line breaks up the elements and set $1..$6 appropriately
>     IFS=":";set $a;unset IFS
>     checkpath $1
>     test $? -eq 0 || continue
>     case $4 in
>     xapp)
> 	xapp $1 "$2" "$3" $5 $6
> 	;;
>     tapp)
> 	tapp $1 "$2" "$3" $6
> 	;;
>     *)
> 	echo `hosed!`
> 	echo $*
>     esac
> done



More information about the Cygwin-xfree mailing list