2000-11-02 21:22:07 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Create menu/desktop entries for an application
|
|
|
|
# This is used by the IShellLink interface
|
|
|
|
#
|
|
|
|
# Copyright 2000 Alexandre Julliard
|
|
|
|
#
|
2002-03-10 00:29:33 +01:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2005-12-19 21:25:52 +01:00
|
|
|
# Note that the link is a relative unix-style path name. Since the / character
|
|
|
|
# is not valid in Windows filenames it is an adequate separator to show the
|
|
|
|
# menu structure. (This program may need to split the menu structure out for
|
|
|
|
# implementing xdg-style menus)
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
mode=""
|
|
|
|
args=""
|
|
|
|
menu=""
|
|
|
|
icon=""
|
|
|
|
descr=""
|
|
|
|
link=""
|
|
|
|
path=""
|
|
|
|
workdir=""
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
usage: wineshelllink options
|
|
|
|
|
|
|
|
options:
|
|
|
|
--desktop create a desktop link
|
|
|
|
--menu create a menu entry
|
|
|
|
--path xx path to the application
|
2005-12-19 21:25:52 +01:00
|
|
|
--link xx name of link to create, including path
|
2000-11-02 21:22:07 +01:00
|
|
|
--args xx command-line arguments for the application
|
|
|
|
--icon xx icon to display
|
|
|
|
--workdir xx working directory for the application
|
|
|
|
--descr xx application description
|
|
|
|
|
|
|
|
EOF
|
2003-09-30 02:28:13 +02:00
|
|
|
exit 2
|
2000-11-02 21:22:07 +01:00
|
|
|
}
|
|
|
|
|
2001-01-17 21:17:03 +01:00
|
|
|
if [ $# -eq 0 ] ; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
2001-12-14 23:45:06 +01:00
|
|
|
--desktop) mode="desktop"; shift 1 ;;
|
|
|
|
--menu) mode="menu"; shift 1 ;;
|
|
|
|
--path) path="$2"; shift 2 ;;
|
|
|
|
--link) link="$2"; shift 2 ;;
|
|
|
|
--args) args="$2"; shift 2 ;;
|
|
|
|
--icon) icon="$2"; shift 2 ;;
|
|
|
|
--descr) descr="$2"; shift 2 ;;
|
|
|
|
--workdir) workdir="$2"; shift 2 ;;
|
|
|
|
*) usage ;;
|
2000-11-02 21:22:07 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2003-09-30 02:28:13 +02:00
|
|
|
if [ -z "$mode" ] ; then
|
|
|
|
echo "Either --desktop or --menu required"
|
2001-01-17 21:17:03 +01:00
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2003-09-30 02:28:13 +02:00
|
|
|
if [ -z "$link" ] ; then
|
|
|
|
echo "You must specify a link name with --link"
|
2001-01-17 21:17:03 +01:00
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
kde_entry()
|
|
|
|
{
|
2001-12-13 01:58:20 +01:00
|
|
|
xname=`basename "$link"`
|
2000-11-02 21:22:07 +01:00
|
|
|
cat <<EOF
|
|
|
|
# KDE Config File
|
|
|
|
[KDE Desktop Entry]
|
2001-12-13 01:58:20 +01:00
|
|
|
Name=$xname
|
2004-09-27 22:32:50 +02:00
|
|
|
Exec=wine '$path' $args
|
2000-11-02 21:22:07 +01:00
|
|
|
Type=Application
|
|
|
|
Comment=$descr
|
|
|
|
EOF
|
|
|
|
[ -z "$workdir" ] || echo "Path=\"$workdir\""
|
|
|
|
[ -z "$xpmicon" ] || echo "Icon=$xpmicon"
|
|
|
|
}
|
|
|
|
|
|
|
|
gnome_entry()
|
|
|
|
{
|
2001-12-13 01:58:20 +01:00
|
|
|
xname=`basename "$link"`
|
2000-11-02 21:22:07 +01:00
|
|
|
cat <<EOF
|
|
|
|
[Desktop Entry]
|
2001-12-13 01:58:20 +01:00
|
|
|
Name=$xname
|
2004-09-27 22:32:50 +02:00
|
|
|
Exec=wine "$path" $args
|
2000-11-02 21:22:07 +01:00
|
|
|
Type=Application
|
|
|
|
Comment=$descr
|
|
|
|
EOF
|
2006-03-26 17:06:54 +02:00
|
|
|
[ -z "$workdir" ] || echo "Path=$workdir"
|
2000-11-02 21:22:07 +01:00
|
|
|
[ -z "$xpmicon" ] || echo "Icon=$xpmicon"
|
|
|
|
}
|
|
|
|
|
2001-11-20 19:53:33 +01:00
|
|
|
mdk_entry()
|
|
|
|
{
|
|
|
|
base=`basename "$link"`
|
|
|
|
section=`dirname "$link"`
|
|
|
|
[ -z "$icon" ] || xicon="icon=\"$xpmicon\""
|
2005-03-10 18:16:22 +01:00
|
|
|
pathmenu=`echo "$path" | sed 's+\\\\+\\\\\\\\+g'`
|
|
|
|
echo "?package(local.Wine):needs=x11 section=\"/Wine/$section\" title=\"$base\" longtitle=\"$descr\" command=\"wine '$pathmenu' $args\" $xicon"
|
2001-11-20 19:53:33 +01:00
|
|
|
}
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
# copy the icon file to a specified dir and set xpmicon to the resulting path
|
|
|
|
copy_icon()
|
|
|
|
{
|
2001-12-13 01:58:20 +01:00
|
|
|
dir="$1"
|
2000-11-02 21:22:07 +01:00
|
|
|
mkdir -p "$dir"
|
2000-12-14 21:30:35 +01:00
|
|
|
mkdir -p "$dir/""`dirname "$link"`" || true
|
2000-11-02 21:22:07 +01:00
|
|
|
if [ -f "$icon" ]
|
|
|
|
then
|
|
|
|
cp "$icon" "$dir/$link.xpm"
|
|
|
|
xpmicon="$dir/$link.xpm"
|
|
|
|
else
|
|
|
|
xpmicon=""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2001-11-20 19:53:33 +01:00
|
|
|
# Debian/Mandrake
|
|
|
|
|
2005-05-09 11:28:05 +02:00
|
|
|
type update-menus > /dev/null 2>&1
|
2001-11-20 19:53:33 +01:00
|
|
|
if [ $? = 0 -a $mode = "menu" ]
|
|
|
|
then
|
|
|
|
iconname="`basename "$link"`.xpm"
|
|
|
|
dir="$HOME/.menu/icons"
|
|
|
|
if [ -f "$icon" ]
|
|
|
|
then
|
2001-12-13 01:58:20 +01:00
|
|
|
mkdir -p "$dir"
|
2001-11-20 19:53:33 +01:00
|
|
|
cp "$icon" "$dir/$iconname"
|
|
|
|
xpmicon="$dir/$iconname"
|
|
|
|
else
|
|
|
|
xpmicon=""
|
|
|
|
fi
|
|
|
|
mdk_entry >> "$HOME/.menu/wine"
|
2005-03-10 18:16:22 +01:00
|
|
|
if [ -d "/usr/lib/menu" ] && [ -w "/usr/lib/menu" ]
|
2002-04-29 21:33:09 +02:00
|
|
|
then
|
|
|
|
mdk_entry >> "/usr/lib/menu/wine"
|
|
|
|
fi
|
2001-11-20 19:53:33 +01:00
|
|
|
update-menus > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
2000-11-02 21:22:07 +01:00
|
|
|
# KDE
|
|
|
|
|
|
|
|
if [ -d "$HOME/.kde" ]
|
|
|
|
then
|
2002-04-29 21:33:09 +02:00
|
|
|
kdeversion=0
|
2005-05-09 11:28:05 +02:00
|
|
|
if type kde-config >/dev/null 2>&1
|
2000-11-02 21:22:07 +01:00
|
|
|
then
|
2002-04-29 21:33:09 +02:00
|
|
|
kdeversion=`kde-config -v | grep KDE: | sed -n "s/^KDE: \([^.]*\)\..*$/\1/p"`
|
|
|
|
fi
|
2001-01-17 21:17:03 +01:00
|
|
|
|
2002-05-15 01:20:45 +02:00
|
|
|
if [ $kdeversion -ge 2 ]
|
2000-11-02 21:22:07 +01:00
|
|
|
then
|
2002-04-29 21:33:09 +02:00
|
|
|
copy_icon "$HOME/.kde/share/applnk/Wine"
|
|
|
|
if [ $mode = "menu" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/.kde/share/applnk/Wine/$link.desktop"
|
|
|
|
elif [ -d "$HOME/Desktop" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop/$link.desktop"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
copy_icon "$HOME/.kde/share/applnk/Wine"
|
|
|
|
if [ $mode = "menu" ]
|
|
|
|
then
|
|
|
|
kde_entry > "$HOME/.kde/share/applnk/Wine/$link.kdelnk"
|
|
|
|
|
|
|
|
# KDE 1.x kludge. Wake up KDE, if we can find kpanel running
|
2005-05-09 11:28:05 +02:00
|
|
|
type kwmcom >/dev/null 2>/dev/null && \
|
2002-04-29 21:33:09 +02:00
|
|
|
ps u -C kpanel >/dev/null 2>/dev/null && \
|
|
|
|
kwmcom kpanel:restart
|
|
|
|
|
|
|
|
elif [ -d "$HOME/Desktop" ]
|
|
|
|
then
|
|
|
|
kde_entry > "$HOME/Desktop/$link.kdelnk"
|
|
|
|
# KDE 1.x kludge: wake up KDE, if we can find kfm running...
|
2005-05-09 11:28:05 +02:00
|
|
|
type kfmclient >/dev/null 2>/dev/null && \
|
2002-04-29 21:33:09 +02:00
|
|
|
ps u -C kfm >/dev/null 2>/dev/null && \
|
|
|
|
kfmclient refreshDesktop
|
|
|
|
fi
|
2000-11-02 21:22:07 +01:00
|
|
|
fi
|
2001-03-08 02:12:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$HOME/.kde2" ]
|
|
|
|
then
|
|
|
|
copy_icon "$HOME/.kde2/share/applnk/Wine"
|
|
|
|
if [ $mode = "menu" ]
|
|
|
|
then
|
2001-03-16 17:40:12 +01:00
|
|
|
gnome_entry > "$HOME/.kde2/share/applnk/Wine/$link.desktop"
|
2002-05-23 18:31:22 +02:00
|
|
|
else
|
|
|
|
if [ -d "$HOME/Desktop2" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop2/$link.desktop"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/Desktop" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop/$link.desktop"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$HOME/.kde3/share/applnk" ]
|
|
|
|
then
|
|
|
|
copy_icon "$HOME/.kde3/share/applnk/Wine"
|
|
|
|
if [ $mode = "menu" ]
|
2001-03-08 02:12:52 +01:00
|
|
|
then
|
2002-05-23 18:31:22 +02:00
|
|
|
gnome_entry > "$HOME/.kde3/share/applnk/Wine/$link.desktop"
|
|
|
|
else
|
|
|
|
if [ -d "$HOME/Desktop3" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop3/$link.desktop"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/Desktop2" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop2/$link.desktop"
|
|
|
|
fi
|
|
|
|
if [ -d "$HOME/Desktop" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/Desktop/$link.desktop"
|
|
|
|
fi
|
2001-03-08 02:12:52 +01:00
|
|
|
fi
|
2000-11-02 21:22:07 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Gnome
|
|
|
|
|
|
|
|
if [ -d "$HOME/.gnome" ]
|
|
|
|
then
|
|
|
|
copy_icon "$HOME/.gnome/apps/Wine"
|
|
|
|
if [ $mode = "menu" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/.gnome/apps/Wine/$link.desktop"
|
|
|
|
elif [ -d "$HOME/.gnome-desktop" ]
|
|
|
|
then
|
|
|
|
gnome_entry > "$HOME/.gnome-desktop/$link.desktop"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|