blob: c1a27b6a4a156e79d2d1ffda710156e06e689eb7 [file] [log] [blame]
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +00001#!/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#
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00008# 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
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000023mode=""
24args=""
25menu=""
26icon=""
27descr=""
28link=""
29path=""
30workdir=""
31
32usage()
33{
34 cat <<EOF
35usage: wineshelllink options
36
37options:
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
47EOF
Francois Gougetbc4f8f92003-09-30 00:28:13 +000048 exit 2
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000049}
50
Jeremy White8dad1d82001-01-17 20:17:03 +000051if [ $# -eq 0 ] ; then
52 usage
53fi
54
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000055while [ $# -gt 0 ]
56do
57 case "$1" in
Simon Walton44b15b182001-12-14 22:45:06 +000058 --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 ;;
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000067 esac
68done
69
Francois Gougetbc4f8f92003-09-30 00:28:13 +000070if [ -z "$mode" ] ; then
71 echo "Either --desktop or --menu required"
Jeremy White8dad1d82001-01-17 20:17:03 +000072 usage
73fi
74
Francois Gougetbc4f8f92003-09-30 00:28:13 +000075if [ -z "$link" ] ; then
76 echo "You must specify a link name with --link"
Jeremy White8dad1d82001-01-17 20:17:03 +000077 usage
78fi
79
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000080kde_entry()
81{
Marcus Meissner9c6af0a2001-12-13 00:58:20 +000082 xname=`basename "$link"`
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000083 cat <<EOF
84# KDE Config File
85[KDE Desktop Entry]
Marcus Meissner9c6af0a2001-12-13 00:58:20 +000086Name=$xname
Marcus Meissnercb54fe62004-09-27 20:32:50 +000087Exec=wine '$path' $args
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000088Type=Application
89Comment=$descr
90EOF
91 [ -z "$workdir" ] || echo "Path=\"$workdir\""
92 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
93}
94
95gnome_entry()
96{
Marcus Meissner9c6af0a2001-12-13 00:58:20 +000097 xname=`basename "$link"`
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +000098 cat <<EOF
99[Desktop Entry]
Marcus Meissner9c6af0a2001-12-13 00:58:20 +0000100Name=$xname
Marcus Meissnercb54fe62004-09-27 20:32:50 +0000101Exec=wine "$path" $args
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000102Type=Application
103Comment=$descr
104EOF
105 [ -z "$workdir" ] || echo "Path=\"$workdir\""
106 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
107}
108
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000109mdk_entry()
110{
111 base=`basename "$link"`
112 section=`dirname "$link"`
113 [ -z "$icon" ] || xicon="icon=\"$xpmicon\""
Marcus Meissnercb54fe62004-09-27 20:32:50 +0000114 echo "?package(local.Wine):needs=x11 section=\"Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine \\\"$path\\\" $args\" $xicon"
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000115}
116
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000117# copy the icon file to a specified dir and set xpmicon to the resulting path
118copy_icon()
119{
Marcus Meissner9c6af0a2001-12-13 00:58:20 +0000120 dir="$1"
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000121 mkdir -p "$dir"
Andreas Mohr1a0eeb52000-12-14 20:30:35 +0000122 mkdir -p "$dir/""`dirname "$link"`" || true
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000123 if [ -f "$icon" ]
124 then
125 cp "$icon" "$dir/$link.xpm"
126 xpmicon="$dir/$link.xpm"
127 else
128 xpmicon=""
129 fi
130}
131
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000132# Debian/Mandrake
133
François Gouget2945c0a2002-01-10 18:19:01 +0000134which update-menus > /dev/null 2>&1
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000135if [ $? = 0 -a $mode = "menu" ]
136then
137 iconname="`basename "$link"`.xpm"
138 dir="$HOME/.menu/icons"
139 if [ -f "$icon" ]
140 then
Marcus Meissner9c6af0a2001-12-13 00:58:20 +0000141 mkdir -p "$dir"
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000142 cp "$icon" "$dir/$iconname"
143 xpmicon="$dir/$iconname"
144 else
145 xpmicon=""
146 fi
147 mdk_entry >> "$HOME/.menu/wine"
Dustin Navea35ba7b92002-04-29 19:33:09 +0000148 if [ -d "/usr/lib/menu" ]
149 then
150 mdk_entry >> "/usr/lib/menu/wine"
151 fi
Dusan Lacko8e44ba12001-11-20 18:53:33 +0000152 update-menus > /dev/null 2>&1
153fi
154
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000155# KDE
156
157if [ -d "$HOME/.kde" ]
158then
Dustin Navea35ba7b92002-04-29 19:33:09 +0000159 kdeversion=0
160 if which kde-config >/dev/null 2>&1
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000161 then
Dustin Navea35ba7b92002-04-29 19:33:09 +0000162 kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"`
163 fi
Jeremy White8dad1d82001-01-17 20:17:03 +0000164
Dustin Navea1222aa62002-05-14 23:20:45 +0000165 if [ $kdeversion -ge 2 ]
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000166 then
Dustin Navea35ba7b92002-04-29 19:33:09 +0000167 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
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000194 fi
Marcus Meissnerb686a902001-03-08 01:12:52 +0000195fi
196
197if [ -d "$HOME/.kde2" ]
198then
199 copy_icon "$HOME/.kde2/share/applnk/Wine"
200 if [ $mode = "menu" ]
201 then
Marcus Meissnered9c2df2001-03-16 16:40:12 +0000202 gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
Dustin Navea9df2e562002-05-23 16:31:22 +0000203 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
213fi
214
215if [ -d "$HOME/.kde3/share/applnk" ]
216then
217 copy_icon "$HOME/.kde3/share/applnk/Wine"
218 if [ $mode = "menu" ]
Dustin Navea1222aa62002-05-14 23:20:45 +0000219 then
Dustin Navea9df2e562002-05-23 16:31:22 +0000220 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
Marcus Meissnerb686a902001-03-08 01:12:52 +0000234 fi
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000235fi
236
Alexandre Julliarde2b4efb2000-11-02 20:22:07 +0000237# Gnome
238
239if [ -d "$HOME/.gnome" ]
240then
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
249fi
250
251exit 0