msi: Add another test for the SourceDir property.
[wine.git] / tools / wineshelllink
blobdb65efa4277c6ddd989814bd1a5a4b4a4ef2d986
1 #!/bin/sh
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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)
28 mode=""
29 args=""
30 menu=""
31 icon=""
32 descr=""
33 link=""
34 path=""
35 workdir=""
37 usage()
39 cat <<EOF
40 usage: wineshelllink options
42 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
52 EOF
53 exit 2
56 if [ $# -eq 0 ] ; then
57 usage
60 while [ $# -gt 0 ]
62 case "$1" in
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 ;;
71 *) usage ;;
72 esac
73 done
75 if [ -z "$mode" ] ; then
76 echo "Either --desktop or --menu required"
77 usage
80 if [ -z "$link" ] ; then
81 echo "You must specify a link name with --link"
82 usage
85 kde_entry()
87 xname=`basename "$link"`
88 cat <<EOF
89 # KDE Config File
90 [KDE Desktop Entry]
91 Name=$xname
92 Exec=wine '$path' $args
93 Type=Application
94 Comment=$descr
95 EOF
96 [ -z "$workdir" ] || echo "Path=\"$workdir\""
97 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
100 gnome_entry()
102 xname=`basename "$link"`
103 cat <<EOF
104 [Desktop Entry]
105 Name=$xname
106 Exec=wine "$path" $args
107 Type=Application
108 Comment=$descr
110 [ -z "$workdir" ] || echo "Path=$workdir"
111 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
114 mdk_entry()
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
124 copy_icon()
126 dir="$1"
127 mkdir -p "$dir"
128 mkdir -p "$dir/""`dirname "$link"`" || true
129 if [ -f "$icon" ]
130 then
131 cp "$icon" "$dir/$link.xpm"
132 xpmicon="$dir/$link.xpm"
133 else
134 xpmicon=""
138 # Debian/Mandrake
140 type update-menus > /dev/null 2>&1
141 if [ $? = 0 -a $mode = "menu" ]
142 then
143 iconname="`basename "$link"`.xpm"
144 dir="$HOME/.menu/icons"
145 if [ -f "$icon" ]
146 then
147 mkdir -p "$dir"
148 cp "$icon" "$dir/$iconname"
149 xpmicon="$dir/$iconname"
150 else
151 xpmicon=""
153 mdk_entry >> "$HOME/.menu/wine"
154 if [ -d "/usr/lib/menu" ] && [ -w "/usr/lib/menu" ]
155 then
156 mdk_entry >> "/usr/lib/menu/wine"
158 update-menus > /dev/null 2>&1
161 # KDE
163 if [ -d "$HOME/.kde" ]
164 then
165 kdeversion=0
166 if type kde-config >/dev/null 2>&1
167 then
168 kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"`
171 if [ $kdeversion -ge 2 ]
172 then
173 copy_icon "$HOME/.kde/share/applnk/Wine"
174 if [ $mode = "menu" ]
175 then
176 gnome_entry > "$HOME/.kde/share/applnk/Wine/$link.desktop"
177 elif [ -d "$HOME/Desktop" ]
178 then
179 gnome_entry > "$HOME/Desktop/$link.desktop"
181 else
182 copy_icon "$HOME/.kde/share/applnk/Wine"
183 if [ $mode = "menu" ]
184 then
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" ]
193 then
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" ]
204 then
205 copy_icon "$HOME/.kde2/share/applnk/Wine"
206 if [ $mode = "menu" ]
207 then
208 gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
209 else
210 if [ -d "$HOME/Desktop2" ]
211 then
212 gnome_entry > "$HOME/Desktop2/$link.desktop"
214 if [ -d "$HOME/Desktop" ]
215 then
216 gnome_entry > "$HOME/Desktop/$link.desktop"
221 if [ -d "$HOME/.kde3/share/applnk" ]
222 then
223 copy_icon "$HOME/.kde3/share/applnk/Wine"
224 if [ $mode = "menu" ]
225 then
226 gnome_entry > "$HOME/.kde3/share/applnk/Wine/$link.desktop"
227 else
228 if [ -d "$HOME/Desktop3" ]
229 then
230 gnome_entry > "$HOME/Desktop3/$link.desktop"
232 if [ -d "$HOME/Desktop2" ]
233 then
234 gnome_entry > "$HOME/Desktop2/$link.desktop"
236 if [ -d "$HOME/Desktop" ]
237 then
238 gnome_entry > "$HOME/Desktop/$link.desktop"
243 # Gnome
245 if [ -d "$HOME/.gnome" ]
246 then
247 copy_icon "$HOME/.gnome/apps/Wine"
248 if [ $mode = "menu" ]
249 then
250 gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop"
251 elif [ -d "$HOME/.gnome-desktop" ]
252 then
253 gnome_entry > "$HOME/.gnome-desktop/$link.desktop"
257 exit 0