Commit | Line | Data |
---|---|---|
e2b4efbd AJ |
1 | #!/bin/sh |
2 | # | |
3 | # Create menu/desktop entries for an application | |
4 | # This is used by the IShellLink interface | |
5 | # | |
6 | # Copyright 2000 Alexandre Julliard | |
7 | # | |
0799c1a7 AJ |
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. | |
12 | # | |
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. | |
17 | # | |
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 | |
21 | # | |
22 | ||
e2b4efbd AJ |
23 | mode="" |
24 | args="" | |
25 | menu="" | |
26 | icon="" | |
27 | descr="" | |
28 | link="" | |
29 | path="" | |
30 | workdir="" | |
31 | ||
32 | usage() | |
33 | { | |
34 | cat <<EOF | |
35 | usage: wineshelllink options | |
36 | ||
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 | |
46 | ||
47 | EOF | |
bc4f8f98 | 48 | exit 2 |
e2b4efbd AJ |
49 | } |
50 | ||
8dad1d8e JW |
51 | if [ $# -eq 0 ] ; then |
52 | usage | |
53 | fi | |
54 | ||
e2b4efbd AJ |
55 | while [ $# -gt 0 ] |
56 | do | |
57 | case "$1" in | |
44b15b18 SW |
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 ;; | |
e2b4efbd AJ |
67 | esac |
68 | done | |
69 | ||
bc4f8f98 FG |
70 | if [ -z "$mode" ] ; then |
71 | echo "Either --desktop or --menu required" | |
8dad1d8e JW |
72 | usage |
73 | fi | |
74 | ||
bc4f8f98 FG |
75 | if [ -z "$link" ] ; then |
76 | echo "You must specify a link name with --link" | |
8dad1d8e JW |
77 | usage |
78 | fi | |
79 | ||
e2b4efbd AJ |
80 | kde_entry() |
81 | { | |
9c6af0a4 | 82 | xname=`basename "$link"` |
e2b4efbd AJ |
83 | cat <<EOF |
84 | # KDE Config File | |
85 | [KDE Desktop Entry] | |
9c6af0a4 | 86 | Name=$xname |
c4e9ea1a | 87 | Exec=wine '$path' -- $args |
e2b4efbd AJ |
88 | Type=Application |
89 | Comment=$descr | |
90 | EOF | |
91 | [ -z "$workdir" ] || echo "Path=\"$workdir\"" | |
92 | [ -z "$xpmicon" ] || echo "Icon=$xpmicon" | |
93 | } | |
94 | ||
95 | gnome_entry() | |
96 | { | |
9c6af0a4 | 97 | xname=`basename "$link"` |
e2b4efbd AJ |
98 | cat <<EOF |
99 | [Desktop Entry] | |
9c6af0a4 | 100 | Name=$xname |
f0cd93f5 | 101 | Exec=wine "$path" -- $args |
e2b4efbd AJ |
102 | Type=Application |
103 | Comment=$descr | |
104 | EOF | |
105 | [ -z "$workdir" ] || echo "Path=\"$workdir\"" | |
106 | [ -z "$xpmicon" ] || echo "Icon=$xpmicon" | |
107 | } | |
108 | ||
8e44ba1c DL |
109 | mdk_entry() |
110 | { | |
111 | base=`basename "$link"` | |
112 | section=`dirname "$link"` | |
113 | [ -z "$icon" ] || xicon="icon=\"$xpmicon\"" | |
f0cd93f5 | 114 | echo "?package(local.Wine):needs=x11 section=\"Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine \\\"$path\\\" -- $args\" $xicon" |
8e44ba1c DL |
115 | } |
116 | ||
e2b4efbd AJ |
117 | # copy the icon file to a specified dir and set xpmicon to the resulting path |
118 | copy_icon() | |
119 | { | |
9c6af0a4 | 120 | dir="$1" |
e2b4efbd | 121 | mkdir -p "$dir" |
1a0eeb53 | 122 | mkdir -p "$dir/""`dirname "$link"`" || true |
e2b4efbd AJ |
123 | if [ -f "$icon" ] |
124 | then | |
125 | cp "$icon" "$dir/$link.xpm" | |
126 | xpmicon="$dir/$link.xpm" | |
127 | else | |
128 | xpmicon="" | |
129 | fi | |
130 | } | |
131 | ||
8e44ba1c DL |
132 | # Debian/Mandrake |
133 | ||
2945c0a8 | 134 | which update-menus > /dev/null 2>&1 |
8e44ba1c DL |
135 | if [ $? = 0 -a $mode = "menu" ] |
136 | then | |
137 | iconname="`basename "$link"`.xpm" | |
138 | dir="$HOME/.menu/icons" | |
139 | if [ -f "$icon" ] | |
140 | then | |
9c6af0a4 | 141 | mkdir -p "$dir" |
8e44ba1c DL |
142 | cp "$icon" "$dir/$iconname" |
143 | xpmicon="$dir/$iconname" | |
144 | else | |
145 | xpmicon="" | |
146 | fi | |
147 | mdk_entry >> "$HOME/.menu/wine" | |
35ba7b9e DN |
148 | if [ -d "/usr/lib/menu" ] |
149 | then | |
150 | mdk_entry >> "/usr/lib/menu/wine" | |
151 | fi | |
8e44ba1c DL |
152 | update-menus > /dev/null 2>&1 |
153 | fi | |
154 | ||
e2b4efbd AJ |
155 | # KDE |
156 | ||
157 | if [ -d "$HOME/.kde" ] | |
158 | then | |
35ba7b9e DN |
159 | kdeversion=0 |
160 | if which kde-config >/dev/null 2>&1 | |
e2b4efbd | 161 | then |
35ba7b9e DN |
162 | kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"` |
163 | fi | |
8dad1d8e | 164 | |
1222aa63 | 165 | if [ $kdeversion -ge 2 ] |
e2b4efbd | 166 | then |
35ba7b9e DN |
167 | copy_icon "$HOME/.kde/share/applnk/Wine" |
168 | if [ $mode = "menu" ] | |
169 | then | |
170 | gnome_entry > "$HOME/.kde/share/applnk/Wine/$link.desktop" | |
171 | elif [ -d "$HOME/Desktop" ] | |
172 | then | |
173 | gnome_entry > "$HOME/Desktop/$link.desktop" | |
174 | fi | |
175 | else | |
176 | copy_icon "$HOME/.kde/share/applnk/Wine" | |
177 | if [ $mode = "menu" ] | |
178 | then | |
179 | kde_entry > "$HOME/.kde/share/applnk/Wine/$link.kdelnk" | |
180 | ||
181 | # KDE 1.x kludge. Wake up KDE, if we can find kpanel running | |
182 | which kwmcom >/dev/null 2>/dev/null && \ | |
183 | ps u -C kpanel >/dev/null 2>/dev/null && \ | |
184 | kwmcom kpanel:restart | |
185 | ||
186 | elif [ -d "$HOME/Desktop" ] | |
187 | then | |
188 | kde_entry > "$HOME/Desktop/$link.kdelnk" | |
189 | # KDE 1.x kludge: wake up KDE, if we can find kfm running... | |
190 | which kfmclient >/dev/null 2>/dev/null && \ | |
191 | ps u -C kfm >/dev/null 2>/dev/null && \ | |
192 | kfmclient refreshDesktop | |
193 | fi | |
e2b4efbd | 194 | fi |
b686a90e MM |
195 | fi |
196 | ||
197 | if [ -d "$HOME/.kde2" ] | |
198 | then | |
199 | copy_icon "$HOME/.kde2/share/applnk/Wine" | |
200 | if [ $mode = "menu" ] | |
201 | then | |
ed9c2df7 | 202 | gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop" |
9df2e56b DN |
203 | else |
204 | if [ -d "$HOME/Desktop2" ] | |
205 | then | |
206 | gnome_entry > "$HOME/Desktop2/$link.desktop" | |
207 | fi | |
208 | if [ -d "$HOME/Desktop" ] | |
209 | then | |
210 | gnome_entry > "$HOME/Desktop/$link.desktop" | |
211 | fi | |
212 | fi | |
213 | fi | |
214 | ||
215 | if [ -d "$HOME/.kde3/share/applnk" ] | |
216 | then | |
217 | copy_icon "$HOME/.kde3/share/applnk/Wine" | |
218 | if [ $mode = "menu" ] | |
b686a90e | 219 | then |
9df2e56b DN |
220 | gnome_entry > "$HOME/.kde3/share/applnk/Wine/$link.desktop" |
221 | else | |
222 | if [ -d "$HOME/Desktop3" ] | |
223 | then | |
224 | gnome_entry > "$HOME/Desktop3/$link.desktop" | |
225 | fi | |
226 | if [ -d "$HOME/Desktop2" ] | |
227 | then | |
228 | gnome_entry > "$HOME/Desktop2/$link.desktop" | |
229 | fi | |
230 | if [ -d "$HOME/Desktop" ] | |
231 | then | |
232 | gnome_entry > "$HOME/Desktop/$link.desktop" | |
233 | fi | |
b686a90e | 234 | fi |
e2b4efbd AJ |
235 | fi |
236 | ||
237 | # Gnome | |
238 | ||
239 | if [ -d "$HOME/.gnome" ] | |
240 | then | |
241 | copy_icon "$HOME/.gnome/apps/Wine" | |
242 | if [ $mode = "menu" ] | |
243 | then | |
244 | gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop" | |
245 | elif [ -d "$HOME/.gnome-desktop" ] | |
246 | then | |
247 | gnome_entry > "$HOME/.gnome-desktop/$link.desktop" | |
248 | fi | |
249 | fi | |
250 | ||
251 | exit 0 |