This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
Re: First pass at script to build start menu icons
- From: "Brian E. Gallew" <geek at burri dot to>
- To: cygwin-xfree at cygwin dot com
- Date: Fri, 08 Aug 2003 11:31:41 -0400
- Subject: Re: First pass at script to build start menu icons
- References: <3F335314.4010109@burri.to> <3F339B6F.7040008@msu.edu>
- Reply-to: cygwin-xfree at cygwin dot com
Harold L Hunt II wrote:
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.
Well, it's trivially easy for me to extract the variables into a file,
e.g., /etc/X11/icon-list, and then dot it in the script.
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.
Possible, sure, but probably too much work. Instead, how about having
the preremove script simply remove all the icons it created? Then the
new one would create a new set of icons and all would be well!
Also, it would be pretty easy to add the remove functionality. In fact,
here's another version! The icon-list file goes in /etc/X11. If you
add a "-d" to the command, it purges only the icons it created, AND any
empty directories under there.
Thanks for contributing Brian, I really appreciate it.
It's the least I can do.
#! /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"
}
# 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::
}
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
# 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":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:
)