Update German resource files.
[wine/multimedia.git] / tools / wineshelllink
blob722ede02b981676c06844f710b659fd9f4c17a9b
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 mode=""
24 args=""
25 menu=""
26 icon=""
27 descr=""
28 link=""
29 path=""
30 workdir=""
32 usage()
34 cat <<EOF
35 usage: wineshelllink options
37 options:
38 --desktop create a desktop link
39 --menu create a menu entry
40 --path xx path to the application
41 --link xx name of link to create
42 --args xx command-line arguments for the application
43 --icon xx icon to display
44 --workdir xx working directory for the application
45 --descr xx application description
47 EOF
48 exit 2
51 if [ $# -eq 0 ] ; then
52 usage
55 while [ $# -gt 0 ]
57 case "$1" in
58 --desktop) mode="desktop"; shift 1 ;;
59 --menu) mode="menu"; shift 1 ;;
60 --path) path="$2"; shift 2 ;;
61 --link) link="$2"; shift 2 ;;
62 --args) args="$2"; shift 2 ;;
63 --icon) icon="$2"; shift 2 ;;
64 --descr) descr="$2"; shift 2 ;;
65 --workdir) workdir="$2"; shift 2 ;;
66 *) usage ;;
67 esac
68 done
70 if [ -z "$mode" ] ; then
71 echo "Either --desktop or --menu required"
72 usage
75 if [ -z "$link" ] ; then
76 echo "You must specify a link name with --link"
77 usage
80 kde_entry()
82 xname=`basename "$link"`
83 cat <<EOF
84 # KDE Config File
85 [KDE Desktop Entry]
86 Name=$xname
87 Exec=wine '$path' $args
88 Type=Application
89 Comment=$descr
90 EOF
91 [ -z "$workdir" ] || echo "Path=\"$workdir\""
92 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
95 gnome_entry()
97 xname=`basename "$link"`
98 cat <<EOF
99 [Desktop Entry]
100 Name=$xname
101 Exec=wine "$path" $args
102 Type=Application
103 Comment=$descr
105 [ -z "$workdir" ] || echo "Path=\"$workdir\""
106 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
109 mdk_entry()
111 base=`basename "$link"`
112 section=`dirname "$link"`
113 [ -z "$icon" ] || xicon="icon=\"$xpmicon\""
114 pathmenu=`echo "$path" | sed 's+\\\\+\\\\\\\\+g'`
115 echo "?package(local.Wine):needs=x11 section=\"/Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine '$pathmenu' $args\" $xicon"
118 # copy the icon file to a specified dir and set xpmicon to the resulting path
119 copy_icon()
121 dir="$1"
122 mkdir -p "$dir"
123 mkdir -p "$dir/""`dirname "$link"`" || true
124 if [ -f "$icon" ]
125 then
126 cp "$icon" "$dir/$link.xpm"
127 xpmicon="$dir/$link.xpm"
128 else
129 xpmicon=""
133 # Debian/Mandrake
135 type update-menus > /dev/null 2>&1
136 if [ $? = 0 -a $mode = "menu" ]
137 then
138 iconname="`basename "$link"`.xpm"
139 dir="$HOME/.menu/icons"
140 if [ -f "$icon" ]
141 then
142 mkdir -p "$dir"
143 cp "$icon" "$dir/$iconname"
144 xpmicon="$dir/$iconname"
145 else
146 xpmicon=""
148 mdk_entry >> "$HOME/.menu/wine"
149 if [ -d "/usr/lib/menu" ] && [ -w "/usr/lib/menu" ]
150 then
151 mdk_entry >> "/usr/lib/menu/wine"
153 update-menus > /dev/null 2>&1
156 # KDE
158 if [ -d "$HOME/.kde" ]
159 then
160 kdeversion=0
161 if type kde-config >/dev/null 2>&1
162 then
163 kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"`
166 if [ $kdeversion -ge 2 ]
167 then
168 copy_icon "$HOME/.kde/share/applnk/Wine"
169 if [ $mode = "menu" ]
170 then
171 gnome_entry > "$HOME/.kde/share/applnk/Wine/$link.desktop"
172 elif [ -d "$HOME/Desktop" ]
173 then
174 gnome_entry > "$HOME/Desktop/$link.desktop"
176 else
177 copy_icon "$HOME/.kde/share/applnk/Wine"
178 if [ $mode = "menu" ]
179 then
180 kde_entry > "$HOME/.kde/share/applnk/Wine/$link.kdelnk"
182 # KDE 1.x kludge. Wake up KDE, if we can find kpanel running
183 type kwmcom >/dev/null 2>/dev/null && \
184 ps u -C kpanel >/dev/null 2>/dev/null && \
185 kwmcom kpanel:restart
187 elif [ -d "$HOME/Desktop" ]
188 then
189 kde_entry > "$HOME/Desktop/$link.kdelnk"
190 # KDE 1.x kludge: wake up KDE, if we can find kfm running...
191 type kfmclient >/dev/null 2>/dev/null && \
192 ps u -C kfm >/dev/null 2>/dev/null && \
193 kfmclient refreshDesktop
198 if [ -d "$HOME/.kde2" ]
199 then
200 copy_icon "$HOME/.kde2/share/applnk/Wine"
201 if [ $mode = "menu" ]
202 then
203 gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
204 else
205 if [ -d "$HOME/Desktop2" ]
206 then
207 gnome_entry > "$HOME/Desktop2/$link.desktop"
209 if [ -d "$HOME/Desktop" ]
210 then
211 gnome_entry > "$HOME/Desktop/$link.desktop"
216 if [ -d "$HOME/.kde3/share/applnk" ]
217 then
218 copy_icon "$HOME/.kde3/share/applnk/Wine"
219 if [ $mode = "menu" ]
220 then
221 gnome_entry > "$HOME/.kde3/share/applnk/Wine/$link.desktop"
222 else
223 if [ -d "$HOME/Desktop3" ]
224 then
225 gnome_entry > "$HOME/Desktop3/$link.desktop"
227 if [ -d "$HOME/Desktop2" ]
228 then
229 gnome_entry > "$HOME/Desktop2/$link.desktop"
231 if [ -d "$HOME/Desktop" ]
232 then
233 gnome_entry > "$HOME/Desktop/$link.desktop"
238 # Gnome
240 if [ -d "$HOME/.gnome" ]
241 then
242 copy_icon "$HOME/.gnome/apps/Wine"
243 if [ $mode = "menu" ]
244 then
245 gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop"
246 elif [ -d "$HOME/.gnome-desktop" ]
247 then
248 gnome_entry > "$HOME/.gnome-desktop/$link.desktop"
252 exit 0