Add Debian/Mandrake menu system support.
[wine/testsucceed.git] / tools / wineshelllink
blobf1544d27b0f2e88820c3b1237ca90e1bc5156b73
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 mode=""
9 args=""
10 menu=""
11 icon=""
12 descr=""
13 link=""
14 path=""
15 workdir=""
17 usage()
19 cat <<EOF
20 usage: wineshelllink options
22 options:
23 --desktop create a desktop link
24 --menu create a menu entry
25 --path xx path to the application
26 --link xx name of link to create
27 --args xx command-line arguments for the application
28 --icon xx icon to display
29 --workdir xx working directory for the application
30 --descr xx application description
32 EOF
33 exit 1
36 if [ $# -eq 0 ] ; then
37 usage
40 while [ $# -gt 0 ]
42 case "$1" in
43 (--desktop) mode="desktop"; shift 1 ;;
44 (--menu) mode="menu"; shift 1 ;;
45 (--path) path=$2; shift 2 ;;
46 (--link) link=$2; shift 2 ;;
47 (--args) args=$2; shift 2 ;;
48 (--icon) icon=$2; shift 2 ;;
49 (--descr) descr=$2; shift 2 ;;
50 (--workdir) workdir=$2; shift 2 ;;
51 (*) usage ;;
52 esac
53 done
55 if [ "$mode" = "" ] ; then
56 echo Either --desktop or --menu required
57 usage
60 if [ "$link" = "" ] ; then
61 echo You must specify a link name with --link
62 usage
65 kde_entry()
67 cat <<EOF
68 # KDE Config File
69 [KDE Desktop Entry]
70 Name=`basename "$link"`
71 Exec=wine "$path" $args
72 Type=Application
73 Comment=$descr
74 EOF
75 [ -z "$workdir" ] || echo "Path=\"$workdir\""
76 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
79 gnome_entry()
81 cat <<EOF
82 [Desktop Entry]
83 Name=`basename "$link"`
84 Exec=wine "$path" $args
85 Type=Application
86 Comment=$descr
87 EOF
88 [ -z "$workdir" ] || echo "Path=\"$workdir\""
89 [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
92 mdk_entry()
94 base=`basename "$link"`
95 section=`dirname "$link"`
96 [ -z "$icon" ] || xicon="icon=\"$xpmicon\""
97 echo "?package(local.Wine):needs=x11 section=\"Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine \\\"$path\\\" $args\" $xicon"
100 # copy the icon file to a specified dir and set xpmicon to the resulting path
101 copy_icon()
103 dir=$1
104 mkdir -p "$dir"
105 mkdir -p "$dir/""`dirname "$link"`" || true
106 if [ -f "$icon" ]
107 then
108 cp "$icon" "$dir/$link.xpm"
109 xpmicon="$dir/$link.xpm"
110 else
111 xpmicon=""
115 # Debian/Mandrake
117 type update-menus > /dev/null 2>&1
118 if [ $? = 0 -a $mode = "menu" ]
119 then
120 iconname="`basename "$link"`.xpm"
121 dir="$HOME/.menu/icons"
122 if [ -f "$icon" ]
123 then
124 mkdir -p $dir
125 cp "$icon" "$dir/$iconname"
126 xpmicon="$dir/$iconname"
127 else
128 xpmicon=""
130 mdk_entry >> "$HOME/.menu/wine"
131 update-menus > /dev/null 2>&1
134 # KDE
136 if [ -d "$HOME/.kde" ]
137 then
138 copy_icon "$HOME/.kde/share/applnk/Wine"
139 if [ $mode = "menu" ]
140 then
141 kde_entry > "$HOME/.kde/share/applnk/Wine/$link.kdelnk"
143 # KDE 1.x kludge. Wake up KDE, if we can find kpanel running
144 type kwmcom >/dev/null 2>/dev/null && \
145 ps u -C kpanel >/dev/null 2>/dev/null && \
146 kwmcom kpanel:restart
148 elif [ -d "$HOME/Desktop" ]
149 then
150 kde_entry > "$HOME/Desktop/$link.kdelnk"
151 # KDE 1.x kludge: wake up KDE, if we can find kfm running...
152 type kfmclient >/dev/null 2>/dev/null && \
153 ps u -C kfm >/dev/null 2>/dev/null && \
154 kfmclient refreshDesktop
158 if [ -d "$HOME/.kde2" ]
159 then
160 copy_icon "$HOME/.kde2/share/applnk/Wine"
161 if [ $mode = "menu" ]
162 then
163 gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
164 elif [ -d "$HOME/Desktop2" ]
165 then
166 gnome_entry > "$HOME/Desktop2/$link.desktop"
173 # Gnome
175 if [ -d "$HOME/.gnome" ]
176 then
177 copy_icon "$HOME/.gnome/apps/Wine"
178 if [ $mode = "menu" ]
179 then
180 gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop"
181 elif [ -d "$HOME/.gnome-desktop" ]
182 then
183 gnome_entry > "$HOME/.gnome-desktop/$link.desktop"
187 exit 0