First pass at script to build start menu icons

Harold L Hunt II huntharo@msu.edu
Sat Aug 9 04:00:00 GMT 2003


Brian,

Couple of things:

1) It seems that we are going to need to somehow get cygwin1.dll in the 
path of the shortcuts.  One way to do this would be to set the working 
dir for each shortcut to '/bin'.  I don't trust 99% of users to 
understand how to set a path variable so that it remains set in Windows, 
so this is going to have to be the default.  We could, of course, 
provide a means to override the working directory.

2) Terminal programs run and exit.  Its like doing Start->Run->ipconfig. 
  The console pops up, lists its output, then is promptly destroyed.  I 
seem to recall an xterm option that caused it to remain open until 
closed manually, but I cannot remember it now.

3) xterm.exe doesn't appear to contain an icon at offset 0.  No icon is 
displayed on my machine.

4) The last section of a line in icon-list is supposed to be for 
arguments, but you don't have an example of how the arguments are to be 
escaped.  I tried a few ideas I had to pass some args to xterm, but none 
of them worked.  Additionally, it doesn't look like the args are 
actually passed.  Am I missing something?  Is this functionality not yet 
implemented?

5) All things DPS are busted on Cygwin/XFree86 because we don't have the 
DPS extension.  I should probably turn off building of them... but they 
could still be used to display on a remote X Server, I think.  In any 
case, icons for the DPS-related programs are probably useless.  Do you 
agree that they should probably be removed?

Thanks again for contributing,

Harold

Brian E. Gallew wrote:
> OK, here's a better set.  It actually sets the right icons and deals 
> correctly with having symlinked programs without the trailing .exe.
> 
> 
> ------------------------------------------------------------------------
> 
> # Yo!  Emacs!  Edit this in -*- shell-script -*- mode!
> 
> # This is the root for the icon creation.
> TOPFOLDER="$(cygpath -A -P)/Cygwin-XFree86"
> 
> #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":Editors: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":Editors:xapp::
> emacs:"Emacs":Editors:xapp::
> xemacs:"XEmacs":Editors:xapp:0:
> idle:"Python IDE":Tools:xapp::
> rxvt:"RXVT"::xapp:0:
> )
> 
> 
> ------------------------------------------------------------------------
> 
> #! /bin/bash
> # Author: Brian Gallew <geek+@cmu.edu>
> 
> # This next line defines TOPFOLDER and X11proggies
> . /etc/X11/icon-list
> 
> #Ensure that a given program is somewhere in the current $PATH
> function checkpath () {
>     c=$(which $1 2> /dev/null)
>     test ! -z "$c"
> }
> 
> #Make sure the program we *think* we're pointing to is the real deal.
> function canonicalize () {
>     a=$(which "$1")
>     while test -h "$a"
>     do
> 	set $(ls -l "$a")
> 	while test ! -z "$2";do shift;done
> 	a=$(dirname "$a")/"$1"
>     done
>     test -f "$a".exe && echo "$a".exe || echo "$a"
> }
> 
> # 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
>     if [ -z "$1" ]
>     then
> 	icon="--icon=/usr/X11R6/bin/run.exe"
> 	ioff="--iconoffset=2"
>     else
> 	icon=--icon=$(canonicalize "$app")
> 	ioff="--iconoffset=$2"
>     fi
>     shift
>     test -d "${folder}" || mkdir -p "${folder}"
>     mkshortcut "${icon}" "${ioff}" --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::
> }
> 
> function create_icons () {
>     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
> }
> 
> function destroy_icons () {
>     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
> 	icon="${TOPFOLDER}/${3}/${2}.lnk"
> 	test -f "${icon}" && \rm -f "${icon}"
>     done
>     find "${TOPFOLDER}" -depth -type d -exec rmdir -v --ignore-fail-on-non-empty "{}" \; 
> }
> 
> function usage () {
>     cat >&2 <<EOF
> Usage: $0 [-d]
> 
> Without any switches, this will recreate the defined icon set.  The
> "-d" switch indicates that all the icons should be removed.  If, after
> the icons are removed, any of the folders are empty, they, too, will
> be removed.
> EOF
>     exit -1
> }
> 
> delete=${1}
> shift
> test -z "$*" || usage
> if [ -z "$delete" ]
> then
>     create_icons
> else
>     test "$delete" = "-d" || usage
>     destroy_icons
> fi



More information about the Cygwin-xfree mailing list