3 # Create menu/desktop entries for an application
4 # This is used by the IShellLink interface
6 # Copyright 2000 Alexandre Julliard
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # Note that the link is a relative unix-style path name. Since the / character
24 # is not valid in Windows filenames it is an adequate separator to show the
25 # menu structure. (This program may need to split the menu structure out for
26 # implementing xdg-style menus)
40 usage: wineshelllink options
43 --desktop create a desktop link
44 --menu create a menu entry
45 --path xx path to the application
46 --link xx name of link to create, including path
47 --args xx command-line arguments for the application
48 --icon xx icon to display
49 --workdir xx working directory for the application
50 --descr xx application description
56 if [ $# -eq 0 ] ; then
63 --desktop) mode="desktop"; shift 1 ;;
64 --menu) mode="menu"; shift 1 ;;
65 --path) path="$2"; shift 2 ;;
66 --link) link="$2"; shift 2 ;;
67 --args) args="$2"; shift 2 ;;
68 --icon) icon="$2"; shift 2 ;;
69 --descr) descr="$2"; shift 2 ;;
70 --workdir) workdir="$2"; shift 2 ;;
75 if [ -z "$mode" ] ; then
76 echo "Either --desktop or --menu required"
80 if [ -z "$link" ] ; then
81 echo "You must specify a link name with --link"
87 xname=`basename "$link"`
92 Exec=wine '$path' $args
96 [ -z "$workdir" ] || echo "Path=\"$workdir\""
97 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
102 xname=`basename "$link"`
106 Exec=wine "$path" $args
110 [ -z "$workdir" ] || echo "Path=\"$workdir\""
111 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
116 base=`basename "$link"`
117 section=`dirname "$link"`
118 [ -z "$icon" ] || xicon="icon=\"$xpmicon\""
119 pathmenu=`echo "$path" | sed 's+\\\\+\\\\\\\\+g'`
120 echo "?package(local.Wine):needs=x11 section=\"/Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine '$pathmenu' $args\" $xicon"
123 # copy the icon file to a specified dir and set xpmicon to the resulting path
128 mkdir -p "$dir/""`dirname "$link"`" || true
131 cp "$icon" "$dir/$link.xpm"
132 xpmicon="$dir/$link.xpm"
140 type update-menus > /dev/null 2>&1
141 if [ $? = 0 -a $mode = "menu" ]
143 iconname="`basename "$link"`.xpm"
144 dir="$HOME/.menu/icons"
148 cp "$icon" "$dir/$iconname"
149 xpmicon="$dir/$iconname"
153 mdk_entry >> "$HOME/.menu/wine"
154 if [ -d "/usr/lib/menu" ] && [ -w "/usr/lib/menu" ]
156 mdk_entry >> "/usr/lib/menu/wine"
158 update-menus > /dev/null 2>&1
163 if [ -d "$HOME/.kde" ]
166 if type kde-config >/dev/null 2>&1
168 kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"`
171 if [ $kdeversion -ge 2 ]
173 copy_icon "$HOME/.kde/share/applnk/Wine"
174 if [ $mode = "menu" ]
176 gnome_entry > "$HOME/.kde/share/applnk/Wine/$link.desktop"
177 elif [ -d "$HOME/Desktop" ]
179 gnome_entry > "$HOME/Desktop/$link.desktop"
182 copy_icon "$HOME/.kde/share/applnk/Wine"
183 if [ $mode = "menu" ]
185 kde_entry > "$HOME/.kde/share/applnk/Wine/$link.kdelnk"
187 # KDE 1.x kludge. Wake up KDE, if we can find kpanel running
188 type kwmcom >/dev/null 2>/dev/null && \
189 ps u -C kpanel >/dev/null 2>/dev/null && \
190 kwmcom kpanel:restart
192 elif [ -d "$HOME/Desktop" ]
194 kde_entry > "$HOME/Desktop/$link.kdelnk"
195 # KDE 1.x kludge: wake up KDE, if we can find kfm running...
196 type kfmclient >/dev/null 2>/dev/null && \
197 ps u -C kfm >/dev/null 2>/dev/null && \
198 kfmclient refreshDesktop
203 if [ -d "$HOME/.kde2" ]
205 copy_icon "$HOME/.kde2/share/applnk/Wine"
206 if [ $mode = "menu" ]
208 gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
210 if [ -d "$HOME/Desktop2" ]
212 gnome_entry > "$HOME/Desktop2/$link.desktop"
214 if [ -d "$HOME/Desktop" ]
216 gnome_entry > "$HOME/Desktop/$link.desktop"
221 if [ -d "$HOME/.kde3/share/applnk" ]
223 copy_icon "$HOME/.kde3/share/applnk/Wine"
224 if [ $mode = "menu" ]
226 gnome_entry > "$HOME/.kde3/share/applnk/Wine/$link.desktop"
228 if [ -d "$HOME/Desktop3" ]
230 gnome_entry > "$HOME/Desktop3/$link.desktop"
232 if [ -d "$HOME/Desktop2" ]
234 gnome_entry > "$HOME/Desktop2/$link.desktop"
236 if [ -d "$HOME/Desktop" ]
238 gnome_entry > "$HOME/Desktop/$link.desktop"
245 if [ -d "$HOME/.gnome" ]
247 copy_icon "$HOME/.gnome/apps/Wine"
248 if [ $mode = "menu" ]
250 gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop"
251 elif [ -d "$HOME/.gnome-desktop" ]
253 gnome_entry > "$HOME/.gnome-desktop/$link.desktop"